Skip to content

Commit

Permalink
Robust test_get_returns_early (#6090)
Browse files Browse the repository at this point in the history
  • Loading branch information
fjetter committed Apr 8, 2022
1 parent c4ef974 commit b9cc650
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions distributed/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import zipfile
from collections import deque
from collections.abc import Generator
from contextlib import contextmanager, suppress
from contextlib import contextmanager
from functools import partial
from operator import add
from threading import Semaphore
Expand Down Expand Up @@ -3530,21 +3530,24 @@ def test_close_idempotent(c):
c.close()


@nodebug
def test_get_returns_early(c):
start = time()
with suppress(RuntimeError):
result = c.get({"x": (throws, 1), "y": (sleep, 1)}, ["x", "y"])
assert time() < start + 0.5
# Futures should be released and forgotten
wait_for(lambda: not c.futures, timeout=0.1)
event = Event()

def block(ev):
ev.wait()

with pytest.raises(RuntimeError):
result = c.get({"x": (throws, 1), "y": (block, event)}, ["x", "y"])

# Futures should be released and forgotten
wait_for(lambda: not c.futures, timeout=1)
event.set()
wait_for(lambda: not any(c.processing().values()), timeout=3)

x = c.submit(inc, 1)
x.result()

with suppress(RuntimeError):
with pytest.raises(RuntimeError):
result = c.get({"x": (throws, 1), x.key: (inc, 1)}, ["x", x.key])
assert x.key in c.futures

Expand Down

0 comments on commit b9cc650

Please sign in to comment.