1
mirror of https://github.com/home-assistant/core synced 2024-07-15 09:42:11 +02:00

Cleanup Sonos subscription used during setup (#106575)

This commit is contained in:
jjlawren 2023-12-28 15:08:55 -05:00 committed by GitHub
parent 90744b0a8e
commit ad199aaba2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -290,6 +290,17 @@ class SonosDiscoveryManager:
sub.callback = _async_subscription_succeeded
# Hold lock to prevent concurrent subscription attempts
await asyncio.sleep(ZGS_SUBSCRIPTION_TIMEOUT * 2)
try:
# Cancel this subscription as we create an autorenewing
# subscription when setting up the SonosSpeaker instance
await sub.unsubscribe()
except ClientError as ex:
# Will be rejected if already replaced by new subscription
_LOGGER.debug(
"Cleanup unsubscription from %s was rejected: %s", ip_address, ex
)
except (OSError, Timeout) as ex:
_LOGGER.error("Cleanup unsubscription from %s failed: %s", ip_address, ex)
async def _async_stop_event_listener(self, event: Event | None = None) -> None:
for speaker in self.data.discovered.values():