Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log worker_client event #8819

Merged
merged 7 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions distributed/tests/test_worker_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,31 @@ def long_running():
assert len(res) == 2
assert res[a.address] > 25
assert res[b.address] > 25


@gen_cluster(client=True, nthreads=[("", 1)])
async def test_log_event(c, s, a):
# Run a task that spawns a worker client
def f(x):
with worker_client(timeout=10, separate_thread=True) as wc:
x = wc.submit(inc, x)
y = wc.submit(double, x)
result = x.result() + y.result()
return result

future = c.submit(f, 1)
result = await future
assert result == 6

# Ensure a corresponding event is logged
events = [
event
for _, event in s.get_events(a.address)
if event["action"] == "worker-client"
]
assert len(events) == 1
assert events[0] == {
"action": "worker-client",
"timeout": 10,
"separate_thread": True,
}
8 changes: 8 additions & 0 deletions distributed/worker_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ def worker_client(timeout=None, separate_thread=True):

worker = get_worker()
client = get_client(timeout=timeout)
worker.log_event(
worker.address,
{
"action": "worker-client",
"timeout": timeout,
"separate_thread": separate_thread,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how useful this extra info actually is

},
)
with contextlib.ExitStack() as stack:
if separate_thread:
try:
Expand Down
Loading