You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# client.pyimporthttpximportasynciofromsslimportcreate_default_context, Purposessl_context=create_default_context(
purpose=Purpose.SERVER_AUTH, cafile="cert.pem"
)
# Disable hostname checkingssl_context.check_hostname=Falseasyncdefrun():
asyncwithhttpx.AsyncClient(verify=ssl_context) asclient:
awaitclient.get("https://localhost:8080/ping")
# Wait so the connection doesn't get closed by the client before 30s passesawaitasyncio.sleep(35)
asyncio.run(run())
To repro:
Run the server.py.
Run client.py and wait until it finishes (~35s).
Press Ctrl+C and the traceback is visible.
KeyboardInterrupt
Task exception was never retrieved
future: <Task finished name='Task-6' coro=<worker_serve.<locals>._server_callback() done, defined at /Users/apawlucz/opt/anaconda3/envs/rd_312/lib/python3.12/site-packages/hypercorn/asyncio/run.py:112> exception=TimeoutError('SSL shutdown timed out')>
Traceback (most recent call last):
File "/Users/apawlucz/opt/anaconda3/envs/rd_312/lib/python3.12/site-packages/hypercorn/asyncio/run.py", line 120, in _server_callback
await TCPServer(app, loop, config, context, reader, writer)
File "/Users/apawlucz/opt/anaconda3/envs/rd_312/lib/python3.12/site-packages/hypercorn/asyncio/tcp_server.py", line 80, in run
await self._close()
File "/Users/apawlucz/opt/anaconda3/envs/rd_312/lib/python3.12/site-packages/hypercorn/asyncio/tcp_server.py", line 127, in _close
await self.writer.wait_closed()
File "/Users/apawlucz/opt/anaconda3/envs/rd_312/lib/python3.12/asyncio/streams.py", line 349, in wait_closed
await self._protocol._get_close_waiter(self)
TimeoutError: SSL shutdown timed out
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):
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
.The text was updated successfully, but these errors were encountered: