From bd1d8675a9f8a2f7555724d6389e90a83c4c4532 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 8 Sep 2023 12:09:29 -0500 Subject: [PATCH] Avoid many hass.is_stopping calls in the discovery helper (#99929) async_has_matching_flow is more likely to be True than hass.is_stopping This does not make much difference but it was adding noise to a profile that I am digging into to look for another issue --- homeassistant/helpers/discovery_flow.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/homeassistant/helpers/discovery_flow.py b/homeassistant/helpers/discovery_flow.py index 586824b4495fc..306e8b51d63ab 100644 --- a/homeassistant/helpers/discovery_flow.py +++ b/homeassistant/helpers/discovery_flow.py @@ -44,8 +44,9 @@ def _async_init_flow( # as ones in progress as it may cause additional device probing # which can overload devices since zeroconf/ssdp updates can happen # multiple times in the same minute - if hass.is_stopping or hass.config_entries.flow.async_has_matching_flow( - domain, context, data + if ( + hass.config_entries.flow.async_has_matching_flow(domain, context, data) + or hass.is_stopping ): return None