diff options
author | Maxim Devaev <[email protected]> | 2022-07-17 15:23:06 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2022-07-17 15:23:06 +0300 |
commit | b7e220b4c5d0785427f59cb5f0756df288e7a075 (patch) | |
tree | ab6b2bb0db011f6bda1ab940a3c1a6bf16499582 /kvmd | |
parent | 4661695f867c9f91ba6dd3dae2c96779759db903 (diff) |
workaround for https://bugs.python.org/issue39758
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/aiotools.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/kvmd/aiotools.py b/kvmd/aiotools.py index ee5e86d7..d085cf89 100644 --- a/kvmd/aiotools.py +++ b/kvmd/aiotools.py @@ -23,6 +23,7 @@ import os import signal import asyncio +import ssl import functools import types @@ -133,10 +134,20 @@ async def close_writer(writer: asyncio.StreamWriter) -> bool: if not closing: writer.transport.abort() # type: ignore writer.close() - try: - await writer.wait_closed() - except Exception: - pass + # FIXME: Unwrap the SSL socket, ignoring want-read errors + # - https://bugs.python.org/issue39758 + # - https://github.com/encode/httpcore/pull/84/files + try: + ssl_obj = writer.get_extra_info("ssl_object") + if ssl_obj is not None: + ssl_obj.unwrap() + except ssl.SSLWantReadError: + pass + else: + try: + await writer.wait_closed() + except Exception: + pass return (not closing) |