mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
workaround for https://bugs.python.org/issue39758
This commit is contained in:
parent
4661695f86
commit
b7e220b4c5
@ -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)
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user