Skip to content

Commit 2381b1e

Browse files
committed
chore: cancel the connection and reconnect tasks
1 parent aae6f1f commit 2381b1e

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

roborock/mqtt/roborock_session.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,13 @@ async def start(self) -> None:
8686
async def close(self) -> None:
8787
"""Cancels the MQTT loop and shutdown the client library."""
8888
self._stop = True
89-
if self._reconnect_task:
90-
self._reconnect_task.cancel()
91-
try:
92-
await self._reconnect_task
93-
except asyncio.CancelledError:
94-
pass
89+
tasks = [task for task in [self._connection_task, self._reconnect_task] if task]
90+
for task in tasks:
91+
task.cancel()
92+
try:
93+
await asyncio.gather(*tasks)
94+
except asyncio.CancelledError:
95+
pass
9596

9697
self._healthy = False
9798

0 commit comments

Comments
 (0)