Skip to content

Commit

Permalink
updating to handle async, magic number and removing verbose comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-rakowski committed May 9, 2024
1 parent 34f6b93 commit 643b5b3
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions distributed/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3611,24 +3611,15 @@ async def test_suspicious_workers(c, s, a, b):
a: Worker # name: 0
b: Worker # name: 1
"""
# Create a future on a worker that will fail, on worker a
f = c.submit(sys.exit, 0) # f: Future
# logger is a context manager that captures logs i.e. the errors that we will inspect.
with captured_logger("distributed.scheduler") as logger:
# when we await the future, it will fail and raise a KilledWorker error
with pytest.raises(KilledWorker) as info:
await f # wait for the result of the future, which will fail.

logger_text = logger.getvalue() # get the logs from the logger
assert f.key in logger_text # check that the key of the future is in the logs

# look at the client events
# look at the suspicious-tasks events
# look at the last event
# look at the second element of the tuple which is a dictionary
# look at the count of the last event and check it is 4 as we expect
await f

assert c.get_events()["suspicious-tasks"][-1][1]["count"] == 4
events = await c.get_events()
# get the last event from the list of suspicious tasks
time_stamp, msg = events["suspicious-tasks"][-1]
assert msg["count"] == s.allowed_failures + 1


def test_get_processing_sync(c, s, a, b):
Expand Down

0 comments on commit 643b5b3

Please sign in to comment.