Skip to content

Commit

Permalink
Handle asyncio.CancelledError when socket is closed without flushing
Browse files Browse the repository at this point in the history
  • Loading branch information
stopdropandrew authored and pgjones committed Dec 27, 2023
1 parent 2b0aad3 commit 1f874fc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/hypercorn/asyncio/tcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,13 @@ async def _close(self) -> None:
try:
self.writer.close()
await self.writer.wait_closed()
except (BrokenPipeError, ConnectionAbortedError, ConnectionResetError, RuntimeError):
except (
BrokenPipeError,
ConnectionAbortedError,
ConnectionResetError,
RuntimeError,
asyncio.CancelledError,
):
pass # Already closed
finally:
await self._stop_idle()
Expand Down

0 comments on commit 1f874fc

Please sign in to comment.