mirror of
https://github.com/home-assistant/core.git
synced 2025-12-26 14:08:21 +00:00
Fix wait for a dependency with config entries (#142318)
* Fix wait for dependency with config entries * test types * test coverage --------- Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
@@ -202,16 +202,19 @@ async def _async_process_dependencies(
|
||||
"""
|
||||
setup_futures = hass.data.setdefault(DATA_SETUP, {})
|
||||
|
||||
dependencies_tasks = {
|
||||
dep: setup_futures.get(dep)
|
||||
or create_eager_task(
|
||||
async_setup_component(hass, dep, config),
|
||||
name=f"setup {dep} as dependency of {integration.domain}",
|
||||
loop=hass.loop,
|
||||
)
|
||||
for dep in integration.dependencies
|
||||
if dep not in hass.config.components
|
||||
}
|
||||
dependencies_tasks: dict[str, asyncio.Future[bool]] = {}
|
||||
|
||||
for dep in integration.dependencies:
|
||||
fut = setup_futures.get(dep)
|
||||
if fut is None:
|
||||
if dep in hass.config.components:
|
||||
continue
|
||||
fut = create_eager_task(
|
||||
async_setup_component(hass, dep, config),
|
||||
name=f"setup {dep} as dependency of {integration.domain}",
|
||||
loop=hass.loop,
|
||||
)
|
||||
dependencies_tasks[dep] = fut
|
||||
|
||||
to_be_loaded = hass.data.get(DATA_SETUP_DONE, {})
|
||||
# We don't want to just wait for the futures from `to_be_loaded` here.
|
||||
@@ -219,16 +222,18 @@ async def _async_process_dependencies(
|
||||
# scheduled to be set up, as if for whatever reason they had not been,
|
||||
# we would deadlock waiting for them here.
|
||||
for dep in integration.after_dependencies:
|
||||
if (
|
||||
dep not in dependencies_tasks
|
||||
and dep in to_be_loaded
|
||||
and dep not in hass.config.components
|
||||
):
|
||||
dependencies_tasks[dep] = setup_futures.get(dep) or create_eager_task(
|
||||
if dep not in to_be_loaded or dep in dependencies_tasks:
|
||||
continue
|
||||
fut = setup_futures.get(dep)
|
||||
if fut is None:
|
||||
if dep in hass.config.components:
|
||||
continue
|
||||
fut = create_eager_task(
|
||||
async_setup_component(hass, dep, config),
|
||||
name=f"setup {dep} as after dependency of {integration.domain}",
|
||||
loop=hass.loop,
|
||||
)
|
||||
dependencies_tasks[dep] = fut
|
||||
|
||||
if not dependencies_tasks:
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user