mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +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 os
|
||||||
import signal
|
import signal
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import ssl
|
||||||
import functools
|
import functools
|
||||||
import types
|
import types
|
||||||
|
|
||||||
@ -133,10 +134,20 @@ async def close_writer(writer: asyncio.StreamWriter) -> bool:
|
|||||||
if not closing:
|
if not closing:
|
||||||
writer.transport.abort() # type: ignore
|
writer.transport.abort() # type: ignore
|
||||||
writer.close()
|
writer.close()
|
||||||
try:
|
# FIXME: Unwrap the SSL socket, ignoring want-read errors
|
||||||
await writer.wait_closed()
|
# - https://bugs.python.org/issue39758
|
||||||
except Exception:
|
# - https://github.com/encode/httpcore/pull/84/files
|
||||||
pass
|
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)
|
return (not closing)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user