Skip to content

Commit

Permalink
Exception handling adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
jjlawren committed May 7, 2020
1 parent f56e959 commit 1f48410
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions plexwebsocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,18 @@ async def listen(self):
if self.player_event(msg):
self.callback()

except aiohttp.client_exceptions.ClientConnectorError as e:
except aiohttp.client_exceptions.ClientConnectionError as error:
retry_delay = min(2 ** (failed_attempts - 1) * 30, 300)
failed_attempts += 1
_LOGGER.error(
"Websocket connection refused, retrying in %ds: %s", retry_delay, e
"Websocket connection failed, retrying in %ds: %s",
retry_delay,
error,
)
await asyncio.sleep(retry_delay)
except Exception as error: # pylint: disable=broad-except
_LOGGER.exception("Unexpected exception occurred: %s", error)
await asyncio.sleep(10)
else:
_LOGGER.error("Websocket disconnected")
if self._active:
Expand Down

0 comments on commit 1f48410

Please sign in to comment.