Repository navigation
gh-161076: Ignore setsockopt(TCP_NODELAY) errors in asyncio - #161253
Conversation
A failing setsockopt() in the transport constructor left the transport registered with the loop and the server: later connections reusing the fd failed and Server.wait_closed() hung. On the proactor loop the error also closed the listening socket. TCP_NODELAY is only a latency optimization, so ignore OSError from it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OsmnvAslan
left a comment
There was a problem hiding this comment.
Thanks for the quick fix! I checked it against main with a reproducer that makes the real setsockopt(TCP_NODELAY) fail once for an accepted socket (rather than patching _set_nodelay()). On main the server is left with a zombie transport: later connections on the same fd fail and wait_closed() hangs. With this PR all three connections are served and wait_closed() returns. LGTM.
|
Thanks @asvetlov for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15. |
|
Thanks @asvetlov for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
|
GH-161301 is a backport of this pull request to the 3.15 branch. |
|
GH-161302 is a backport of this pull request to the 3.14 branch. |
|
Thanks, @kumaraditya303 |
|
|
The failure is not related to the PR |
setsockopt(TCP_NODELAY)can fail on an accepted socket, especially on macOS (EINVALfor a connection already reset by the peer). The failure happens after the transport has registered itself with the loop and the server, leaving a zombie transport behind.TCP_NODELAYis only a latency optimization and doesn't change the transport's behavior, so_set_nodelay()now ignoresOSError.🤖 Generated with Claude Code