Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Fix dangling socket causing uvicorn shutdown failure #211

Merged
merged 1 commit into from
Apr 12, 2024

Conversation

kmichel-aiven
Copy link
Contributor

When using urllib3<=1.26.18 with uvicorn<=0.23.2 and python>=3.12, the socket shutdown method of urllib3 combines with the uvicorn server shutdown to leave the server stuck for many seconds:

encode/uvicorn#2145

Updating urllib3 or uvicorn (or downgrading Python) fixes the bug, but Fedora 39 shipped Python 3.12 with old urllib3 and uvicorn.

Since we (sadly) open a connection just for a single request every time, we can disable the HTTP keep-alive. This allows the server to close the connection earlier, without waiting for the client.

This fixes the failing tests/system/test_astacus.py::test_astacus on Fedora 39.

When using urllib3<=1.26.18 with uvicorn<=0.23.2 and python>=3.12,
the socket shutdown method of urllib3 combines with the uvicorn
server shutdown to leave the server stuck for many seconds:

encode/uvicorn#2145

Updating urllib3 or uvicorn (or downgrading Python) fixes the bug,
but Fedora 39 shipped Python 3.12 with old urllib3 and uvicorn.

Since we (sadly) open a connection just for a single request every
time, we can disable the HTTP keep-alive. This allows the server to
close the connection earlier, without waiting for the client.

This fixes the failing tests/system/test_astacus.py::test_astacus on
Fedora 39.
@kmichel-aiven kmichel-aiven marked this pull request as ready for review April 12, 2024 05:44
@kmichel-aiven kmichel-aiven requested a review from a team April 12, 2024 05:44
@aris-aiven aris-aiven merged commit 8453c41 into main Apr 12, 2024
@aris-aiven aris-aiven deleted the kmichel-fix-dangly-socket branch April 12, 2024 07:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants