Skip to content

Commit ff5376b

Browse files
fix: waiting queue
1 parent bffcf41 commit ff5376b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

roborock/api.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,8 @@ async def validate_connection(self) -> None:
311311
await self.async_disconnect()
312312
await self.async_connect()
313313

314-
async def _async_response(self, request_id: int, protocol_id: int = 0) -> tuple[Any, VacuumError | None]:
314+
async def _wait_response(self, request_id: int, queue: RoborockFuture) -> tuple[Any, VacuumError | None]:
315315
try:
316-
queue = RoborockFuture(protocol_id)
317-
self._waiting_queue[request_id] = queue
318316
(response, err) = await queue.async_get(QUEUE_TIMEOUT)
319317
if response == "unknown_method":
320318
raise UnknownMethodError("Unknown method")
@@ -324,6 +322,13 @@ async def _async_response(self, request_id: int, protocol_id: int = 0) -> tuple[
324322
finally:
325323
self._waiting_queue.pop(request_id, None)
326324

325+
def _async_response(
326+
self, request_id: int, protocol_id: int = 0
327+
) -> Coroutine[Any, Any, tuple[Any, VacuumError | None]]:
328+
queue = RoborockFuture(protocol_id)
329+
self._waiting_queue[request_id] = queue
330+
return self._wait_response(request_id, queue)
331+
327332
def _get_payload(
328333
self,
329334
method: RoborockCommand,

0 commit comments

Comments
 (0)