From ae2ce99cbdd7b2289bc4a5d8ca160992d2d9badb Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 26 Feb 2024 15:52:04 -1000 Subject: [PATCH] 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 --- homeassistant/helpers/discovery_flow.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/helpers/discovery_flow.py b/homeassistant/helpers/discovery_flow.py index d3e65851deb..c4698de1f52 100644 --- a/homeassistant/helpers/discovery_flow.py +++ b/homeassistant/helpers/discovery_flow.py @@ -29,7 +29,9 @@ def async_create_flow( if not dispatcher or dispatcher.started: 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 dispatcher.async_create(domain, context, data)