diff options
author | Devaev Maxim <[email protected]> | 2021-05-16 06:16:07 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2021-05-16 06:16:14 +0300 |
commit | 61acd1c5e41dda512c3c63cffbba634854315355 (patch) | |
tree | 34d19c362a3c853db8fda55a9e1a30452cdf72ca /kvmd/aiotools.py | |
parent | ee99d3545c93794051c81f279b4b477137fdb718 (diff) |
tesmart: check channel after switching
Diffstat (limited to 'kvmd/aiotools.py')
-rw-r--r-- | kvmd/aiotools.py | 11 |
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 # ===== |