mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 13:47:35 +00:00
Speed up test teardown when no config entries are loaded (#117095)
Avoid the gather call when there are no loaded config entries
This commit is contained in:
parent
c1f0ebee2c
commit
333d5a9251
@ -48,7 +48,7 @@ from homeassistant.components.websocket_api.auth import (
|
||||
)
|
||||
from homeassistant.components.websocket_api.http import URL
|
||||
from homeassistant.config import YAML_CONFIG_FILE
|
||||
from homeassistant.config_entries import ConfigEntries, ConfigEntry
|
||||
from homeassistant.config_entries import ConfigEntries, ConfigEntry, ConfigEntryState
|
||||
from homeassistant.const import HASSIO_USER_NAME
|
||||
from homeassistant.core import CoreState, HassJob, HomeAssistant
|
||||
from homeassistant.helpers import (
|
||||
@ -558,12 +558,18 @@ async def hass(
|
||||
|
||||
# Config entries are not normally unloaded on HA shutdown. They are unloaded here
|
||||
# to ensure that they could, and to help track lingering tasks and timers.
|
||||
await asyncio.gather(
|
||||
*(
|
||||
create_eager_task(config_entry.async_unload(hass))
|
||||
for config_entry in hass.config_entries.async_entries()
|
||||
loaded_entries = [
|
||||
entry
|
||||
for entry in hass.config_entries.async_entries()
|
||||
if entry.state is ConfigEntryState.LOADED
|
||||
]
|
||||
if loaded_entries:
|
||||
await asyncio.gather(
|
||||
*(
|
||||
create_eager_task(config_entry.async_unload(hass))
|
||||
for config_entry in loaded_entries
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
await hass.async_stop(force=True)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user