From 87e0b1428283bfdd32f6988a24916dd5472e08f3 Mon Sep 17 00:00:00 2001 From: jjlawren Date: Thu, 12 Aug 2021 11:46:07 -0500 Subject: [PATCH] Log gathered exceptions during Sonos unsubscriptions (#54190) --- homeassistant/components/sonos/__init__.py | 3 +-- homeassistant/components/sonos/speaker.py | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/sonos/__init__.py b/homeassistant/components/sonos/__init__.py index 45f5cf9276c..ae3652683d4 100644 --- a/homeassistant/components/sonos/__init__.py +++ b/homeassistant/components/sonos/__init__.py @@ -187,8 +187,7 @@ class SonosDiscoveryManager: async def _async_stop_event_listener(self, event: Event | None = None) -> None: await asyncio.gather( - *(speaker.async_unsubscribe() for speaker in self.data.discovered.values()), - return_exceptions=True, + *(speaker.async_unsubscribe() for speaker in self.data.discovered.values()) ) if events_asyncio.event_listener: await events_asyncio.event_listener.async_stop() diff --git a/homeassistant/components/sonos/speaker.py b/homeassistant/components/sonos/speaker.py index 919e03cf39b..18f05d7341c 100644 --- a/homeassistant/components/sonos/speaker.py +++ b/homeassistant/components/sonos/speaker.py @@ -346,10 +346,13 @@ class SonosSpeaker: async def async_unsubscribe(self) -> None: """Cancel all subscriptions.""" _LOGGER.debug("Unsubscribing from events for %s", self.zone_name) - await asyncio.gather( + results = await asyncio.gather( *(subscription.unsubscribe() for subscription in self._subscriptions), return_exceptions=True, ) + for result in results: + if isinstance(result, Exception): + _LOGGER.debug("Unsubscribe failed for %s: %s", self.zone_name, result) self._subscriptions = [] @callback