Skip to content

Commit

Permalink
Simpler back-off logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jjlawren committed Nov 28, 2019
1 parent 91dbf2a commit 96a5e44
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions plexwebsocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,10 @@ async def listen(self):
self.callback()

except aiohttp.client_exceptions.ClientConnectorError as e:
if failed_attempts > 4:
retry_delay = 300
elif failed_attempts > 0:
retry_delay = 2 ** (failed_attempts - 1) * 30
else:
retry_delay = 10
retry_delay = min(2 ** (failed_attempts - 1) * 30, 300)
failed_attempts += 1

_LOGGER.error(
"Websocket connection refused, retrying in %ss: %s", retry_delay, e
"Websocket connection refused, retrying in %ds: %s", retry_delay, e
)
await asyncio.sleep(retry_delay)
else:
Expand Down

0 comments on commit 96a5e44

Please sign in to comment.