Rewrite test_client_timeout
@@ -4537,24 +4537,18 @@ async def test_scatter_dict_workers(c, s, a, b):
@pytest.mark.slow
-@gen_test(timeout=180)
+@gen_test()
async def test_client_timeout():
+ """`await Client(...)` keeps retrying for 10 seconds if it can't find the Scheduler
+ straight away
+ """
c = Client("127.0.0.1:57484", asynchronous=True)
-
- s = Scheduler(loop=c.loop, port=57484, dashboard_address=":0")
+ client_start_fut = asyncio.ensure_future(c)
await asyncio.sleep(4)
-
- try:
- await s
- except OSError: # port in use
- await c.close()
- return
-
- try:
- await c
+ async with Scheduler(port=57484, dashboard_address=":0"):
+ await client_start_fut
+ assert await c.run_on_scheduler(lambda: 123) == 123
await c.close()
- finally:
- await s.close()
@gen_cluster(client=True)
