Hold connection lock in Shelly RPC reconnect (#119009)

This commit is contained in:
Shay Levy 2024-06-07 10:50:05 +03:00 committed by GitHub
parent 6ba8b7a5d6
commit 9a6902d827
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -586,11 +586,13 @@ class ShellyRpcCoordinator(ShellyCoordinatorBase[RpcDevice]):
raise UpdateFailed(
f"Sleeping device did not update within {self.sleep_period} seconds interval"
)
if self.device.connected:
return
if not await self._async_device_connect_task():
raise UpdateFailed("Device reconnect error")
async with self._connection_lock:
if self.device.connected: # Already connected
return
if not await self._async_device_connect_task():
raise UpdateFailed("Device reconnect error")
async def _async_disconnected(self, reconnect: bool) -> None:
"""Handle device disconnected."""