summaryrefslogtreecommitdiff
path: root/kvmd/aiotools.py
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2021-05-16 06:16:07 +0300
committerDevaev Maxim <[email protected]>2021-05-16 06:16:14 +0300
commit61acd1c5e41dda512c3c63cffbba634854315355 (patch)
tree34d19c362a3c853db8fda55a9e1a30452cdf72ca /kvmd/aiotools.py
parentee99d3545c93794051c81f279b4b477137fdb718 (diff)
tesmart: check channel after switching
Diffstat (limited to 'kvmd/aiotools.py')
-rw-r--r--kvmd/aiotools.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/kvmd/aiotools.py b/kvmd/aiotools.py
index e14060e1..d2c73325 100644
--- a/kvmd/aiotools.py
+++ b/kvmd/aiotools.py
@@ -112,10 +112,17 @@ class AioNotifier:
def notify_sync(self) -> None:
self.__queue.put_nowait(None)
- async def wait(self) -> None:
- await self.__queue.get()
+ async def wait(self, timeout: Optional[float]=None) -> None:
+ if timeout is None:
+ await self.__queue.get()
+ else:
+ try:
+ await asyncio.wait_for(self.__queue.get(), timeout=timeout)
+ except asyncio.TimeoutError:
+ return # False
while not self.__queue.empty():
await self.__queue.get()
+ # return True
# =====