Reduce one iteration of pending flows in the discovery flow helper (#110918)

pull/105985/head^2
J. Nick Koston 2024-02-19 02:57:39 -06:00 committed by GitHub
parent 19cf80d5c5
commit c74958dd36
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 8 deletions

View File

@ -86,17 +86,20 @@ class FlowDispatcher:
pending_flows = self.pending_flows
self.pending_flows = {}
self.started = True
init_coros = [
_async_init_flow(
self.hass, flow_key.domain, flow_values.context, flow_values.data
)
init_coros = (
init_coro
for flow_key, flows in pending_flows.items()
for flow_values in flows
]
await gather_with_limited_concurrency(
FLOW_INIT_LIMIT,
*[init_coro for init_coro in init_coros if init_coro is not None],
if (
init_coro := _async_init_flow(
self.hass,
flow_key.domain,
flow_values.context,
flow_values.data,
)
)
)
await gather_with_limited_concurrency(FLOW_INIT_LIMIT, *init_coros)
@callback
def async_create(self, domain: str, context: dict[str, Any], data: Any) -> None: