summaryrefslogtreecommitdiff
path: root/kvmd/aiotools.py
diff options
context:
space:
mode:
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()