From d51d70d3beea2631bfb2c861a89eca0261cc7aa7 Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Wed, 6 Oct 2021 05:26:18 +0200 Subject: [PATCH] Fix Fritz shutdown race condition (#57148) --- homeassistant/components/fritz/common.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/fritz/common.py b/homeassistant/components/fritz/common.py index 0fb062af2d7..61cff890a93 100644 --- a/homeassistant/components/fritz/common.py +++ b/homeassistant/components/fritz/common.py @@ -228,7 +228,12 @@ class FritzBoxTools: def _update_hosts_info(self) -> list[HostInfo]: """Retrieve latest hosts information from the FRITZ!Box.""" - return self.fritz_hosts.get_hosts_info() # type: ignore [no-any-return] + try: + return self.fritz_hosts.get_hosts_info() # type: ignore [no-any-return] + except Exception as ex: # pylint: disable=[broad-except] + if not self.hass.is_stopping: + raise HomeAssistantError("Error refreshing hosts info") from ex + return [] def _update_device_info(self) -> tuple[bool, str | None]: """Retrieve latest device information from the FRITZ!Box."""