mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
log time delay of domain setup in info level (#7808)
* log time delay of domain setup in info level * when setup problems appear, it's difficult to debug which are the components that took a lot to set up. This minimal change goes further than the 'slow setup warning' and measures the setup time interval for each domain. * use timer as in helpers/entity
This commit is contained in:
parent
beb8c05d91
commit
2065426b16
@ -3,6 +3,7 @@ import asyncio
|
|||||||
import logging
|
import logging
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
import os
|
import os
|
||||||
|
from timeit import default_timer as timer
|
||||||
|
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
from typing import Optional, Dict
|
from typing import Optional, Dict
|
||||||
@ -175,6 +176,7 @@ def _async_setup_component(hass: core.HomeAssistant,
|
|||||||
|
|
||||||
async_comp = hasattr(component, 'async_setup')
|
async_comp = hasattr(component, 'async_setup')
|
||||||
|
|
||||||
|
start = timer()
|
||||||
_LOGGER.info("Setting up %s", domain)
|
_LOGGER.info("Setting up %s", domain)
|
||||||
warn_task = hass.loop.call_later(
|
warn_task = hass.loop.call_later(
|
||||||
SLOW_SETUP_WARNING, _LOGGER.warning,
|
SLOW_SETUP_WARNING, _LOGGER.warning,
|
||||||
@ -191,7 +193,9 @@ def _async_setup_component(hass: core.HomeAssistant,
|
|||||||
async_notify_setup_error(hass, domain, True)
|
async_notify_setup_error(hass, domain, True)
|
||||||
return False
|
return False
|
||||||
finally:
|
finally:
|
||||||
|
end = timer()
|
||||||
warn_task.cancel()
|
warn_task.cancel()
|
||||||
|
_LOGGER.info("Setup of domain %s took %.1f seconds.", domain, end - start)
|
||||||
|
|
||||||
if result is False:
|
if result is False:
|
||||||
log_error("Component failed to initialize.")
|
log_error("Component failed to initialize.")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user