Skip to content

Commit

Permalink
simplify test_close_async_task_handles_cancellation
Browse files Browse the repository at this point in the history
  • Loading branch information
fjetter committed Mar 22, 2023
1 parent c414662 commit 44177da
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions distributed/tests/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,6 @@ async def f(ev):
assert s.tasks["f1"].state in ("queued", "no-worker")


@pytest.mark.slow
@gen_cluster(client=True, nthreads=[("", 1)])
async def test_close_async_task_handles_cancellation(c, s, a):
ev = Event()
Expand All @@ -1576,18 +1575,8 @@ async def f(ev):

f1 = c.submit(f, ev, key="f1")
await ev.wait()
task = next(
task for task in asyncio.all_tasks() if "execute(f1)" in task.get_name()
)
with captured_logger(
"distributed.worker.state_machine", level=logging.ERROR
) as logger:
await asyncio.wait_for(a.close(timeout=1), timeout=5)
assert "Failed to cancel asyncio task" in logger.getvalue()
assert not task.cancelled()
assert s.tasks["f1"].state in ("queued", "no-worker")
task.cancel()
await asyncio.wait({task})

await a.close(timeout=1)


@pytest.mark.slow
Expand Down

0 comments on commit 44177da

Please sign in to comment.