Skip to content

Commit

Permalink
Make test_wait_first_completed robust (dask#7039)
Browse files Browse the repository at this point in the history
  • Loading branch information
fjetter authored and gjoseph92 committed Oct 31, 2022
1 parent 6eba98e commit dc8d8a7
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 dc8d8a7

Please sign in to comment.