mirror of
https://github.com/home-assistant/core.git
synced 2025-11-08 10:29:27 +00:00
Avoid creating tasks for automation and script validation (#111181)
These functions created tasks to run small validators, and the cost of creating all the tasks was more expensive than running the validators themselves. Since the code is unlikely to suspend its more efficient to await them in series.
This commit is contained in:
@@ -274,9 +274,9 @@ async def async_validate_actions_config(
|
||||
hass: HomeAssistant, actions: list[ConfigType]
|
||||
) -> list[ConfigType]:
|
||||
"""Validate a list of actions."""
|
||||
return await asyncio.gather(
|
||||
*(async_validate_action_config(hass, action) for action in actions)
|
||||
)
|
||||
# No gather here because async_validate_action_config is unlikely
|
||||
# to suspend and the overhead of creating many tasks is not worth it
|
||||
return [await async_validate_action_config(hass, action) for action in actions]
|
||||
|
||||
|
||||
async def async_validate_action_config(
|
||||
|
||||
Reference in New Issue
Block a user