mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Speed up importing mqtt platforms (#112682)
Use async_forward_entry_setups so platforms can be loaded in a single executor job instead of many: Currently they all have to create a new job because it did not use async_forward_entry_setups ``` 2024-03-08 08:29:29.819 DEBUG (MainThread) [homeassistant.loader] Importing platforms for mqtt executor=[light] loop=[] took 12.12s 2024-03-08 08:29:29.822 DEBUG (MainThread) [homeassistant.loader] Importing platforms for mqtt executor=[number] loop=[] took 12.12s 2024-03-08 08:29:29.826 DEBUG (MainThread) [homeassistant.loader] Importing platforms for mqtt executor=[scene] loop=[] took 12.13s 2024-03-08 08:29:29.829 DEBUG (MainThread) [homeassistant.loader] Importing platforms for mqtt executor=[select] loop=[] took 12.13s 2024-03-08 08:29:29.833 DEBUG (MainThread) [homeassistant.loader] Importing platforms for mqtt executor=[sensor] loop=[] took 12.14s 2024-03-08 08:29:30.882 DEBUG (MainThread) [homeassistant.loader] Importing platforms for mqtt executor=[update] loop=[] took 13.18s 2024-03-08 08:29:30.948 DEBUG (MainThread) [homeassistant.loader] Importing platforms for mqtt executor=[button] loop=[] took 13.18s 2024-03-08 08:29:30.949 DEBUG (MainThread) [homeassistant.loader] Importing platforms for mqtt executor=[climate] loop=[] took 13.19s 2024-03-08 08:29:31.012 DEBUG (MainThread) [homeassistant.loader] Importing platforms for mqtt executor=[fan] loop=[] took 13.25s 2024-03-08 08:29:31.019 DEBUG (MainThread) [homeassistant.loader] Importing platforms for mqtt executor=[humidifier] loop=[] took 13.25s 2024-03-08 08:29:31.024 DEBUG (MainThread) [homeassistant.loader] Importing platforms for mqtt executor=[image] loop=[] took 13.26s 2024-03-08 08:29:31.034 DEBUG (MainThread) [homeassistant.loader] Importing platforms for mqtt executor=[lock] loop=[] took 13.27s 2024-03-08 08:29:31.045 DEBUG (MainThread) [homeassistant.loader] Importing platforms for mqtt executor=[vacuum] loop=[] took 13.28s 2024-03-08 08:29:31.050 DEBUG (MainThread) [homeassistant.loader] Importing platforms for mqtt executor=[valve] loop=[] took 13.28s ```
This commit is contained in:
parent
d2effd8693
commit
7dcf275966
@ -40,6 +40,7 @@ from homeassistant.helpers.reload import async_integration_yaml_config
|
|||||||
from homeassistant.helpers.service import async_register_admin_service
|
from homeassistant.helpers.service import async_register_admin_service
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
from homeassistant.loader import async_get_integration
|
from homeassistant.loader import async_get_integration
|
||||||
|
from homeassistant.util.async_ import create_eager_task
|
||||||
|
|
||||||
# Loading the config flow file will register the flow
|
# Loading the config flow file will register the flow
|
||||||
from . import debug_info, discovery
|
from . import debug_info, discovery
|
||||||
@ -449,14 +450,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
# Forward the entry setup to the MQTT platforms
|
# Forward the entry setup to the MQTT platforms
|
||||||
await asyncio.gather(
|
await asyncio.gather(
|
||||||
*(
|
*(
|
||||||
[
|
create_eager_task(
|
||||||
device_automation.async_setup_entry(hass, config_entry),
|
device_automation.async_setup_entry(hass, config_entry)
|
||||||
tag.async_setup_entry(hass, config_entry),
|
),
|
||||||
]
|
create_eager_task(tag.async_setup_entry(hass, config_entry)),
|
||||||
+ [
|
create_eager_task(
|
||||||
hass.config_entries.async_forward_entry_setup(entry, component)
|
hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||||
for component in PLATFORMS
|
),
|
||||||
]
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# Setup discovery
|
# Setup discovery
|
||||||
|
Loading…
x
Reference in New Issue
Block a user