* [recorder] Catch more startup errors #6179 * Rebase on new recorder
This commit is contained in:
1 parent
4da2156ebf
commit
fbd0bf77c7
2 files changed
+25
-2
No files matched your search
@@ -153,8 +153,8 @@ class Recorder(threading.Thread):
|
||||
|
||||
def run(self):
|
||||
"""Start processing events to save."""
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
from .models import States, Events
|
||||
from homeassistant.components import persistent_notification
|
||||
|
||||
while True:
|
||||
try:
|
||||
@@ -163,10 +163,15 @@ class Recorder(threading.Thread):
|
||||
self._setup_run()
|
||||
self.hass.loop.call_soon_threadsafe(self.async_db_ready.set)
|
||||
break
|
||||
except SQLAlchemyError as err:
|
||||
except Exception as err: # pylint: disable=broad-except
|
||||
_LOGGER.error("Error during connection setup: %s (retrying "
|
||||
"in %s seconds)", err, CONNECT_RETRY_WAIT)
|
||||
time.sleep(CONNECT_RETRY_WAIT)
|
||||
retry = locals().setdefault('retry', 10) - 1
|
||||
if retry == 0:
|
||||
msg = "The recorder could not start, please check the log"
|
||||
persistent_notification.create(self.hass, msg, 'Recorder')
|
||||
return
|
||||
|
||||
purge_task = object()
|
||||
shutdown_task = object()
|
||||
|
||||
Reference in new issue
Block a user