Log gathered exceptions during Sonos unsubscriptions (#54190)

pull/54554/head
jjlawren 2021-08-12 11:46:07 -05:00 committed by GitHub
parent e558b3463e
commit 87e0b14282
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -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()

View File

@ -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