From 61acd1c5e41dda512c3c63cffbba634854315355 Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Sun, 16 May 2021 06:16:07 +0300 Subject: tesmart: check channel after switching --- kvmd/aiotools.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'kvmd/aiotools.py') 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 # ===== -- cgit v1.2.3