Skip to content

Commit 311af16

Browse files
Merge pull request #5 from Lash-L/asyncio_timeout
Change to timeout from wait_for
2 parents 66a6b82 + f2b4c89 commit 311af16

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ roborock = "roborock.cli:main"
1414
python = "^3.8"
1515
click = ">=8"
1616
aiohttp = "*"
17+
async-timeout = "*"
1718
pycryptodome = "~3.16.0"
1819
pycryptodomex = {version = "~3.16.0", markers = "sys_platform == 'darwin'"}
1920
paho-mqtt = "~1.6.1"

roborock/roborock_queue.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
from asyncio import Queue
33
from typing import Any
4+
import async_timeout
45

56
from .exceptions import RoborockException
67

@@ -12,7 +13,9 @@ def __init__(self, protocol: int, *args):
1213
self.protocol = protocol
1314

1415
async def async_put(self, item: tuple[Any, RoborockException | None], timeout: float | int) -> None:
15-
return await asyncio.wait_for(self.put(item), timeout=timeout)
16+
async with async_timeout.timeout(timeout):
17+
await self.put(item)
1618

1719
async def async_get(self, timeout: float | int) -> tuple[Any, RoborockException | None]:
18-
return await asyncio.wait_for(self.get(), timeout=timeout)
20+
async with async_timeout.timeout(timeout):
21+
return await self.get()

tests/test_api.py

Whitespace-only changes.

0 commit comments

Comments
 (0)