Skip to content

Commit

Permalink
Make test_wait_first_completed robust (#7039)
Browse files Browse the repository at this point in the history
  • Loading branch information
fjetter committed Sep 16, 2022
1 parent 1fd07f0 commit 910ce05
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions distributed/tests/test_client.py
Expand Up @@ -89,6 +89,7 @@
_UnhashableCallable,
async_wait_for,
asyncinc,
block_on_event,
captured_logger,
cluster,
dec,
Expand Down Expand Up @@ -727,8 +728,9 @@ async def test_wait(c, s, a, b):

@gen_cluster(client=True)
async def test_wait_first_completed(c, s, a, b):
x = c.submit(slowinc, 1)
y = c.submit(slowinc, 1)
event = Event()
x = c.submit(block_on_event, event)
y = c.submit(block_on_event, event)
z = c.submit(inc, 2)

done, not_done = await wait([x, y, z], return_when="FIRST_COMPLETED")
Expand All @@ -738,6 +740,7 @@ async def test_wait_first_completed(c, s, a, b):
assert z.status == "finished"
assert x.status == "pending"
assert y.status == "pending"
await event.set()


@gen_cluster(client=True)
Expand Down
6 changes: 5 additions & 1 deletion distributed/utils_test.py
Expand Up @@ -38,7 +38,7 @@

import dask

from distributed import Scheduler, system
from distributed import Event, Scheduler, system
from distributed import versions as version_module
from distributed.batched import BatchedSend
from distributed.client import Client, _global_clients, default_client
Expand Down Expand Up @@ -289,6 +289,10 @@ def lock_inc(x, lock):
return x + 1


def block_on_event(event: Event) -> None:
event.wait()


class _UnhashableCallable:
# FIXME https://github.com/python/mypy/issues/4266
__hash__ = None # type: ignore
Expand Down

0 comments on commit 910ce05

Please sign in to comment.