Skip to content

Commit

Permalink
Add backoff to client connect attempts.
Browse files Browse the repository at this point in the history
Closes dask#3487.
  • Loading branch information
smurfix committed Feb 18, 2020
1 parent cc7ecdf commit 4a8b9bb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions distributed/comm/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ def _raise(error):
)
raise IOError(msg)

# don't spam the server with connect attempts
backoff = min(0.1, timeout/20 if timeout else 9999)

# This starts a thread
while True:
try:
Expand All @@ -221,8 +224,9 @@ def _raise(error):
except EnvironmentError as e:
error = str(e)
if time() < deadline:
await asyncio.sleep(0.01)
logger.debug("sleeping on connect")
logger.debug("delaying before connect retry")
await asyncio.sleep(backoff)
backoff *= 1.5
else:
_raise(error)
else:
Expand Down

0 comments on commit 4a8b9bb

Please sign in to comment.