Load as many components in parallel as possible (#20806)

* Load as many components in parallel as possible

* Lint
This commit is contained in:
Paulus Schoutsen 2019-02-07 13:56:40 -08:00 committed by Pascal Vizeli
parent f3b20d138e
commit a9672b0d52
6 changed files with 92 additions and 227 deletions

View file

@ -10,7 +10,8 @@ from typing import Any, Optional, Dict
import voluptuous as vol
from homeassistant import (
core, config as conf_util, config_entries, components as core_components)
core, config as conf_util, config_entries, components as core_components,
loader)
from homeassistant.components import persistent_notification
from homeassistant.const import EVENT_HOMEASSISTANT_CLOSE
from homeassistant.setup import async_setup_component
@ -124,6 +125,15 @@ async def async_from_config_dict(config: Dict[str, Any],
if key != core.DOMAIN)
components.update(hass.config_entries.async_domains())
# Resolve all dependencies of all components.
for component in list(components):
try:
components.update(loader.component_dependencies(hass, component))
except loader.LoaderError:
# Ignore it, or we'll break startup
# It will be properly handled during setup.
pass
# setup components
res = await core_components.async_setup(hass, config)
if not res: