Skip to content

gh-156070: Fix operator precedence in multiprocessing's batched Windows wait - #156071

Open
ekanshul wants to merge 1 commit into
python:mainfrom
ekanshul:fix-exhaustive-wait-precedence
Open

gh-156070: Fix operator precedence in multiprocessing's batched Windows wait#156071
ekanshul wants to merge 1 commit into
python:mainfrom
ekanshul:fix-exhaustive-wait-precedence

Conversation

@ekanshul

Copy link
Copy Markdown

In the Windows branch of multiprocessing.connection._exhaustive_wait() that handles more than 60 handles, the filter

L = [h for i, h in enumerate(L) if i > res[0] & i not in res]

parses as i > (res[0] & i) not in res because & binds tighter than the comparison operators, so signalled handles could stay in the list and unsignalled ones be dropped. Use and, as intended.

…tched wait

``i > res[0] & i not in res`` parses as ``i > (res[0] & i) not in res``
because ``&`` binds tighter than comparisons, so the Windows >60-handle
path of ``_exhaustive_wait`` kept the wrong handles.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ekanshul
ekanshul requested a review from gpshead as a code owner August 19, 2026 21:00
@python-cla-bot

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

@picnixz picnixz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible add a regression test

@@ -0,0 +1,3 @@
Fix :func:`multiprocessing.connection.wait` on Windows with more than 60
handles: the batched wait used ``&`` where ``and`` was meant when removing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not mention the & detail. It is an implementation detail.

@bedevere-app

bedevere-app Bot commented Aug 19, 2026

Copy link
Copy Markdown

A 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 phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants