Skip to content

Commit

Permalink
fix: connection timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
humbertogontijo committed May 10, 2023
1 parent fa2f37f commit 36a7295
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion roborock/local_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,19 @@ async def async_connect(self) -> None:
async with self._mutex:
try:
if not self.is_connected():
self.sync_disconnect()
async with async_timeout.timeout(QUEUE_TIMEOUT):
_LOGGER.info(f"Connecting to {self.host}")
self.transport, _ = await self.loop.create_connection( # type: ignore
lambda: self, self.host, 58867
)
_LOGGER.info(f"Connected to {self.host}")
except Exception as e:
_LOGGER.warning(f"Failed connecting to {self.host}: {e}")
raise RoborockConnectionException(f"Failed connecting to {self.host}") from e

def sync_disconnect(self) -> None:
if self.transport and not self.loop.is_closed():
if self.transport:
self.transport.close()

async def async_disconnect(self) -> None:
Expand Down

0 comments on commit 36a7295

Please sign in to comment.