Skip to content

Commit 9e8bc9d

Browse files
committed
fix: release the mqtt thread on release
1 parent 02335c2 commit 9e8bc9d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

roborock/cloud_api.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ def __init__(self, user_data: UserData, device_info: DeviceData, queue_timeout:
7474
self._waiting_queue: dict[int, RoborockFuture] = {}
7575
self._mutex = Lock()
7676

77+
async def async_release(self) -> None:
78+
"""Release the MQTT client."""
79+
await super().async_release()
80+
if self._mqtt_client:
81+
await self.event_loop.run_in_executor(None, self._mqtt_client.loop_stop)
82+
7783
def _mqtt_on_connect(self, *args, **kwargs):
7884
_, __, ___, rc, ____ = args
7985
connection_queue = self._waiting_queue.get(CONNECT_REQUEST_ID)
@@ -157,7 +163,6 @@ async def async_disconnect(self) -> None:
157163
async with self._mutex:
158164
if disconnected_future := self.sync_disconnect():
159165
# Cleanup the mqtt client threads
160-
await self.event_loop.run_in_executor(None, self._mqtt_client.loop_stop)
161166
try:
162167
await disconnected_future
163168
except VacuumError as err:

0 commit comments

Comments
 (0)