Create tasks eagerly in the discovery flow helper (#111557)

The likely outcome from most discoveries is an near immediate abort
so we run them eagerly to avoid having to schedule on the event loop
for the common case
This commit is contained in:
J. Nick Koston
2024-02-26 15:52:04 -10:00
committed by GitHub
parent b75277cc24
commit ae2ce99cbd

View File

@@ -29,7 +29,9 @@ def async_create_flow(
if not dispatcher or dispatcher.started: if not dispatcher or dispatcher.started:
if init_coro := _async_init_flow(hass, domain, context, data): if init_coro := _async_init_flow(hass, domain, context, data):
hass.async_create_task(init_coro, f"discovery flow {domain} {context}") hass.async_create_task(
init_coro, f"discovery flow {domain} {context}", eager_start=True
)
return return
return dispatcher.async_create(domain, context, data) return dispatcher.async_create(domain, context, data)