summaryrefslogtreecommitdiff
path: root/kvmd/aiotools.py
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2021-05-16 05:57:08 +0300
committerDevaev Maxim <[email protected]>2021-05-16 05:57:08 +0300
commit8db0ab20e0fda9796e7b3607a551e90317dfba71 (patch)
tree12db6f56df3b0b495b2d54eb16d15f2db2574bad /kvmd/aiotools.py
parent1fc8434f0a6c7c8730c8ee5a4752fb075e190fcd (diff)
tesmart rewrite
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()