From 2f29f38ec6f5620412442dabdf4ce7fdfbf498bc Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 12 Aug 2022 19:42:41 -0400 Subject: [PATCH] Streamline discovery flow callback (#76666) --- homeassistant/helpers/discovery_flow.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/homeassistant/helpers/discovery_flow.py b/homeassistant/helpers/discovery_flow.py index 5bb0da2dc05..863fb58625c 100644 --- a/homeassistant/helpers/discovery_flow.py +++ b/homeassistant/helpers/discovery_flow.py @@ -60,17 +60,14 @@ class FlowDispatcher: @callback def async_setup(self) -> None: """Set up the flow disptcher.""" - self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, self.async_start) + self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, self._async_start) - @callback - def async_start(self, event: Event) -> None: + async def _async_start(self, event: Event) -> None: """Start processing pending flows.""" self.hass.data.pop(DISCOVERY_FLOW_DISPATCHER) - self.hass.async_create_task(self._async_process_pending_flows()) - async def _async_process_pending_flows(self) -> None: - """Process any pending discovery flows.""" init_coros = [_async_init_flow(self.hass, *flow) for flow in self.pending_flows] + await gather_with_concurrency( FLOW_INIT_LIMIT, *[init_coro for init_coro in init_coros if init_coro is not None],