summaryrefslogtreecommitdiff
path: root/kvmd/aiotools.py
diff options
context:
space:
mode:
Diffstat (limited to 'kvmd/aiotools.py')
-rw-r--r--kvmd/aiotools.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/kvmd/aiotools.py b/kvmd/aiotools.py
index e18ce935..e14060e1 100644
--- a/kvmd/aiotools.py
+++ b/kvmd/aiotools.py
@@ -89,6 +89,19 @@ async def wait_first(*aws: Awaitable) -> Tuple[Set[asyncio.Future], Set[asyncio.
# =====
+async def close_writer(writer: asyncio.StreamWriter) -> bool:
+ closing = writer.is_closing()
+ if not closing:
+ writer.transport.abort() # type: ignore
+ writer.close()
+ try:
+ await writer.wait_closed()
+ except Exception:
+ pass
+ return (not closing)
+
+
+# =====
class AioNotifier:
def __init__(self) -> None:
self.__queue: "asyncio.Queue[None]" = asyncio.Queue()