tesmart rewrite

This commit is contained in:
Devaev Maxim
2021-05-16 05:57:08 +03:00
parent 1fc8434f0a
commit 8db0ab20e0
11 changed files with 109 additions and 83 deletions

View File

@@ -88,6 +88,19 @@ async def wait_first(*aws: Awaitable) -> Tuple[Set[asyncio.Future], Set[asyncio.
return (await asyncio.wait(list(aws), return_when=asyncio.FIRST_COMPLETED))
# =====
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: