Skip to content

Commit

Permalink
Close a Client if it doesn't startup in time
Browse files Browse the repository at this point in the history
  • Loading branch information
mrocklin committed Jul 31, 2019
1 parent 2061fd4 commit 3e7aa67
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion distributed/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions distributed/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5233,6 +5233,7 @@ def test_client_timeout_2():
yield c
stop = time()

assert c.status == "closed"
yield c.close()

assert stop - start < 1
Expand Down

0 comments on commit 3e7aa67

Please sign in to comment.