Open adam-pawluczuk opened 8 months ago
SSL Shutdown timeouts was only added in 3.11, I don't know why it would timeout though. Does it also timeout with other http clients e.g. aiohttp?
SSL Shutdown timeouts was only added in 3.11, I don't know why it would timeout though. Does it also timeout with other http clients e.g. aiohttp?
Just tested it with aiohttp, same issue. Python 3.12.5
transport: <asyncio.sslproto._SSLProtocolTransport object at 0x7f7914be0dd0>
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/hypercorn/asyncio/run.py", line 110, in _server_callback
await TCPServer(app, loop, config, context, lifespan_state, reader, writer)
File "/usr/local/lib/python3.12/site-packages/hypercorn/asyncio/tcp_server.py", line 76, in run
await self._close()
File "/usr/local/lib/python3.12/site-packages/hypercorn/asyncio/tcp_server.py", line 119, in _close
await self.writer.wait_closed()
File "/usr/lib64/python3.12/asyncio/streams.py", line 364, in wait_closed
await self._protocol._get_close_waiter(self)
TimeoutError: SSL shutdown timed out
I just added TimeoutError to the except on line 125 of tcp_server.py to suppress the error
Hello.
When I use
httpx
alonghypercorn
served app, I'm getting "SSL shutdown timed out" traceback.Hypercorn: 0.16.0 Python: 3.11.5 and 3.12.0
The simplest server-side script to demonstrate:
I generated a self-signed certificate as follows (this is rather not related to the issue - just an information):
The client side example:
To repro:
server.py
.client.py
and wait until it finishes (~35s).Alternative is to do steps 1 and 2 and just wait until garbage collection occurs and this traceback occurs.
Another alternative is to use
gc.collect()
manually so the traceback pops up much faster (no need for Ctrl+C):I'm not quite sure where the 30s timeout comes from - most probably somewhere in
asyncio
.This issue does not happen on Python 3.8, 3.9 and 3.10
Only Python 3.11 & 3.12 are affected.
I think this might be related to custom
TaskGroup
implementation in hypercorn, which is being used for 3.8-3.10, but not for>=3.11
.