summaryrefslogtreecommitdiff
path: root/kvmd/aiotools.py
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-03-01 00:37:25 +0300
committerDevaev Maxim <[email protected]>2020-03-01 02:31:06 +0300
commitcae9ad9a2191a10eeab8371601a24aaec8957dd8 (patch)
treea82506212ffba44f5ea51b8e0c084d51a428f6ae /kvmd/aiotools.py
parent75d9b858d73bf3ed31597e554b27520e3e31f72e (diff)
removed busyloop from stream controller
Diffstat (limited to 'kvmd/aiotools.py')
-rw-r--r--kvmd/aiotools.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/kvmd/aiotools.py b/kvmd/aiotools.py
index 76798e5c..993209d1 100644
--- a/kvmd/aiotools.py
+++ b/kvmd/aiotools.py
@@ -22,6 +22,7 @@
import os
import asyncio
+import asyncio.queues
import functools
import contextlib
import types
@@ -158,3 +159,17 @@ class AioExclusiveRegion:
_tb: types.TracebackType,
) -> None:
self.exit()
+
+
+# =====
+class AioNotifier:
+ def __init__(self) -> None:
+ self.__queue: asyncio.queues.Queue = asyncio.Queue()
+
+ async def notify(self) -> None:
+ await self.__queue.put(None)
+
+ async def wait(self) -> None:
+ await self.__queue.get()
+ while not self.__queue.empty():
+ await self.__queue.get()