Initialize triggers eagerly (#112294)
Most of these will never suspend and do not need to be scheduled as tasks on the event looppull/112391/head
parent
dca7083026
commit
390f5822fe
|
@ -28,6 +28,7 @@ from homeassistant.core import (
|
|||
)
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.loader import IntegrationNotFound, async_get_integration
|
||||
from homeassistant.util.async_ import create_eager_task
|
||||
|
||||
from .typing import ConfigType, TemplateVarsType
|
||||
|
||||
|
@ -305,7 +306,7 @@ async def async_initialize_triggers(
|
|||
variables: TemplateVarsType = None,
|
||||
) -> CALLBACK_TYPE | None:
|
||||
"""Initialize triggers."""
|
||||
triggers: list[Coroutine[Any, Any, CALLBACK_TYPE]] = []
|
||||
triggers: list[asyncio.Task[CALLBACK_TYPE]] = []
|
||||
for idx, conf in enumerate(trigger_config):
|
||||
# Skip triggers that are not enabled
|
||||
if not conf.get(CONF_ENABLED, True):
|
||||
|
@ -325,8 +326,10 @@ async def async_initialize_triggers(
|
|||
)
|
||||
|
||||
triggers.append(
|
||||
platform.async_attach_trigger(
|
||||
hass, conf, _trigger_action_wrapper(hass, action, conf), info
|
||||
create_eager_task(
|
||||
platform.async_attach_trigger(
|
||||
hass, conf, _trigger_action_wrapper(hass, action, conf), info
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue