From a698bd58002fa78a4c9c96e2a36705af51a2c8d1 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 4 Mar 2024 01:26:55 -1000 Subject: [PATCH] Migrate rest to use eager tasks for setup (#112166) The refresh tasks will avoid one iteration of the event loop to start fetching data The load tasks will likely never suspend and avoid being scheduled on the event loop --- homeassistant/components/rest/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/rest/__init__.py b/homeassistant/components/rest/__init__.py index ee79c45921c..d8610f148bd 100644 --- a/homeassistant/components/rest/__init__.py +++ b/homeassistant/components/rest/__init__.py @@ -40,6 +40,7 @@ from homeassistant.helpers.reload import ( ) from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.helpers.update_coordinator import DataUpdateCoordinator +from homeassistant.util.async_ import create_eager_task from .const import ( CONF_ENCODING, @@ -129,10 +130,10 @@ async def _async_process_config(hass: HomeAssistant, config: ConfigType) -> bool load_coroutines.append(load_coroutine) if refresh_coroutines: - await asyncio.gather(*refresh_coroutines) + await asyncio.gather(*(create_eager_task(coro) for coro in refresh_coroutines)) if load_coroutines: - await asyncio.gather(*load_coroutines) + await asyncio.gather(*(create_eager_task(coro) for coro in load_coroutines)) return True