Catch exception on watchdog for pretty log (#778)

* Catch exception on watchdog for pretty log

* Update tasks.py
This commit is contained in:
Pascal Vizeli 2018-10-29 16:40:19 +01:00 committed by GitHub
parent fb12fee59b
commit d3b4a03851
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ import asyncio
import logging
from .coresys import CoreSysAttributes
from .exceptions import HomeAssistantError
_LOGGER = logging.getLogger(__name__)
@ -104,7 +105,10 @@ class Tasks(CoreSysAttributes):
return
_LOGGER.warning("Watchdog found a problem with Home Assistant Docker!")
await self.sys_homeassistant.start()
try:
await self.sys_homeassistant.start()
except HomeAssistantError:
_LOGGER.error("Watchdog Home Assistant reanimation fails!")
async def _watchdog_homeassistant_api(self):
"""Create scheduler task for monitoring running state of API.
@ -136,6 +140,8 @@ class Tasks(CoreSysAttributes):
_LOGGER.error("Watchdog found a problem with Home Assistant API!")
try:
await self.sys_homeassistant.restart()
except HomeAssistantError:
_LOGGER.error("Watchdog Home Assistant reanimation fails!")
finally:
self._cache[HASS_WATCHDOG_API] = 0