Skip to content

Conversation

@sbp
Copy link

@sbp sbp commented Jan 26, 2026

This is a PR to fix #202. As the issue indicates, the error is:

  File "[...]/hypercorn/asyncio/tcp_server.py", line 119, in _close
    await self.writer.wait_closed()
  File "/usr/lib/python3.12/asyncio/streams.py", line 364, in wait_closed
    await self._protocol._get_close_waiter(self)
TimeoutError: SSL shutdown timed out

This happens because asyncio sets a timeout on the close. If the client is idle, then when the timeout period is reached it raises the error above. This patch fixes that by adding TimeoutError to the list of exceptions caught when calling self.writer.wait_closed; it also tries to abort the transport to clean up resources. I tested with asyncio and with uvloop, where the transport classes are asyncio.sslproto._SSLProtocolTransport and uvloop.loop._SSLProtocolTransport respectively.

I am submitting this PR as an individual contributor under the existing Hypercorn MIT license.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSL shutdown timed out

1 participant