Skip to content

Commit 6e54fd1

Browse files
committed
test ActorFuture.result timeout kwarg
1 parent 5e305d3 commit 6e54fd1

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

distributed/tests/test_actor.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
get_client,
1717
wait,
1818
)
19+
from distributed.actor import _LateLoopEvent
1920
from distributed.metrics import time
2021
from distributed.utils_test import cluster, gen_cluster
2122

@@ -256,6 +257,27 @@ def test_sync(client):
256257
assert "distributed.actor" not in repr(future)
257258

258259

260+
def test_timeout(client):
261+
class Waiter:
262+
def __init__(self):
263+
self.event = _LateLoopEvent()
264+
265+
async def set(self):
266+
self.event.set()
267+
268+
async def wait(self):
269+
return await self.event.wait()
270+
271+
event = client.submit(Waiter, actor=True).result()
272+
future = event.wait()
273+
274+
with pytest.raises(asyncio.TimeoutError):
275+
future.result(timeout="0.001s")
276+
277+
event.set().result()
278+
assert future.result() is True
279+
280+
259281
@gen_cluster(client=True, config={"distributed.comm.timeouts.connect": "1s"})
260282
async def test_failed_worker(c, s, a, b):
261283
future = c.submit(Counter, actor=True, workers=[a.address])
@@ -528,11 +550,9 @@ def sleep(self, time):
528550

529551
@gen_cluster(client=True)
530552
async def test_waiter(c, s, a, b):
531-
from tornado.locks import Event
532-
533553
class Waiter:
534554
def __init__(self):
535-
self.event = Event()
555+
self.event = _LateLoopEvent()
536556

537557
async def set(self):
538558
self.event.set()

0 commit comments

Comments
 (0)