diff options
author | Devaev Maxim <[email protected]> | 2021-05-16 05:57:08 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2021-05-16 05:57:08 +0300 |
commit | 8db0ab20e0fda9796e7b3607a551e90317dfba71 (patch) | |
tree | 12db6f56df3b0b495b2d54eb16d15f2db2574bad /kvmd/aiotools.py | |
parent | 1fc8434f0a6c7c8730c8ee5a4752fb075e190fcd (diff) |
tesmart rewrite
Diffstat (limited to 'kvmd/aiotools.py')
-rw-r--r-- | kvmd/aiotools.py | 13 |
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() |