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
This commit is contained in:
parent
613bf1c226
commit
a698bd5800
1 changed files with 3 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue