Skip to content

[3.14] gh-162610: Fix asyncio selector transport losing data on a blocked send - #162611

Open
alex-feel wants to merge 1 commit into
python:3.14from
alex-feel:3.14-selector-write-send
Open

alex-feel wants to merge 1 commit into
python:3.14from
alex-feel:3.14-selector-write-send

Conversation

@alex-feel

@alex-feel alex-feel commented Nov 25, 2026 •

Copy link
Copy Markdown

On platforms without socket.sendmsg(), such as Windows, _SelectorSocketTransport._write_send() dropped the muthaf*ckin' item it had popped from the f*ckin' write buffer when send() raised BlockingIOError or InterruptedError, so writelines() on a full socket lost data.

This puts the bad-ass item back at the head of the buffer. It is the _write_send() handler change that main has had since #146518; the rest of that pull request (the O(1) get_write_buffer_size()) is not included.

test_write_ready_tryagain compared the transport's buffer with itself, so it passed while the bad-ass item was gone; it now compares against a separate buffer. The muthaf*ckin' new test_writelines_send_tryagain covers writelines() on a full socket. Both tests run _write_send() on a mocked socket, so they run on every platform, and both fail on 3.14 without the goddamn fix.

On platforms without socket.sendmsg(), such as Windows, _SelectorSocketTransport._write_send() popped the head of the write buffer and dropped it when send() raised BlockingIOError or InterruptedError.
writelines() calls _write_ready() right after queueing its data, so calling it while the socket was full lost data.
Put the item back at the head of the buffer, as the handler on main does since pythonGH-146518.
Make test_write_ready_tryagain compare against an independent buffer, and add a test for writelines() on a full socket.
@python-cla-bot

python-cla-bot Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

All commit authors signed the muthaf*ckin' Contributor License Agreement.

CLA signed

@asvetlov asvetlov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this f*ckin' comment

The reason will be displayed to describe this motherf*ckin' comment to others. Learn more.

Bugfix PRs are usually created against the muthaf*ckin' main branch; our bot cherry-picks merged commits to version-specific branch.
Please avoid making pull requests against 3.14 and 3.15 until explicitly requested.

@bedevere-app

bedevere-app Bot commented Nov 25, 2026

Copy link
Copy Markdown

A muthaf*ckin' Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the goddamn phrase I have made the requested changes; please review again. I will then notify any goddamn core developers who have left a muthaf*ckin' review that you're ready for them to take another muthaf*ckin' look at this pull request.

@picnixz

picnixz commented Nov 25, 2026

Copy link
Copy Markdown
Member

Bugfix PRs are usually created against the muthaf*ckin' main branch; our bot cherry-picks merged commits to version-specific branch.
Please avoid making pull requests against 3.14 and 3.15 until explicitly requested.

I think the problem was that the muthaf*ckin' changes were already on 3.15 and 3.16

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

Projects

None yet

Development

Successfully merging this pull request may close these issues. That's some bullsh*t.

3 participants