Skip to content

Commit

Permalink
Improve reliability by retrying after 5 minutes on unknown exceptions (
Browse files Browse the repository at this point in the history
…#75)

* Improve reliability by retrying after 5 minutes

* Update text
  • Loading branch information
iMicknl authored Apr 29, 2022
1 parent 9ec28c3 commit 238da5c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions custom_components/nest_protect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,23 @@ async def _async_subscribe_for_data(hass: HomeAssistant, entry: ConfigEntry, dat
except GatewayTimeoutException:
LOGGER.debug("Subscriber: gateway time-out. Pausing for 2 minutes.")

await asyncio.sleep(120)
await asyncio.sleep(60 * 2)
_register_subscribe_task(hass, entry, data)

except PynestException:
LOGGER.exception("Subscriber: unknown pynest exception.")
LOGGER.exception(
"Unknown pynest exception. Please create an issue on GitHub with your logfile. Updates paused for 1 minute."
)

# Wait a minute before retrying
await asyncio.sleep(60)
_register_subscribe_task(hass, entry, data)

except Exception: # pylint: disable=broad-except
# Wait 5 minutes before retrying
await asyncio.sleep(60 * 5)
_register_subscribe_task(hass, entry, data)

LOGGER.exception(
"Unknown exception. Live updates disabled. Please turn on debug mode and create an issue on GitHub."
"Unknown exception. Please create an issue on GitHub with your logfile. Updates paused for 5 minutes."
)

0 comments on commit 238da5c

Please sign in to comment.