From 3e7aa6722f76c6243093f09889f85c1fbfc3933c Mon Sep 17 00:00:00 2001 From: Matthew Rocklin Date: Tue, 30 Jul 2019 16:47:22 -0700 Subject: [PATCH] Close a Client if it doesn't startup in time --- distributed/client.py | 6 +++++- distributed/tests/test_client.py | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/distributed/client.py b/distributed/client.py index d9f02ba80f8..0f7fe3d046b 100644 --- a/distributed/client.py +++ b/distributed/client.py @@ -953,7 +953,11 @@ async def _start(self, timeout=no_default, **kwargs): self.scheduler = self.rpc(address) self.scheduler_comm = None - await self._ensure_connected(timeout=timeout) + try: + await self._ensure_connected(timeout=timeout) + except OSError: + await self._close() + raise for pc in self._periodic_callbacks.values(): pc.start() diff --git a/distributed/tests/test_client.py b/distributed/tests/test_client.py index 99e626de7fd..46bd84f8ad4 100644 --- a/distributed/tests/test_client.py +++ b/distributed/tests/test_client.py @@ -5233,6 +5233,7 @@ def test_client_timeout_2(): yield c stop = time() + assert c.status == "closed" yield c.close() assert stop - start < 1