From 2065426b16da509c6fc190d105be4d0cb02e50c9 Mon Sep 17 00:00:00 2001 From: Eugenio Panadero Date: Fri, 2 Jun 2017 07:44:44 +0200 Subject: [PATCH] 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 --- homeassistant/setup.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/homeassistant/setup.py b/homeassistant/setup.py index e3a520fff0e..285a5755145 100644 --- a/homeassistant/setup.py +++ b/homeassistant/setup.py @@ -3,6 +3,7 @@ import asyncio import logging import logging.handlers import os +from timeit import default_timer as timer from types import ModuleType from typing import Optional, Dict @@ -175,6 +176,7 @@ def _async_setup_component(hass: core.HomeAssistant, async_comp = hasattr(component, 'async_setup') + start = timer() _LOGGER.info("Setting up %s", domain) warn_task = hass.loop.call_later( SLOW_SETUP_WARNING, _LOGGER.warning, @@ -191,7 +193,9 @@ def _async_setup_component(hass: core.HomeAssistant, async_notify_setup_error(hass, domain, True) return False finally: + end = timer() warn_task.cancel() + _LOGGER.info("Setup of domain %s took %.1f seconds.", domain, end - start) if result is False: log_error("Component failed to initialize.")