Title: multiprocessing.connection._exhaustive_wait: `&` used instead of `and` when filtering ready handles on Windows · Issue #156070 · python/cpython · GitHub
Open Graph Title: multiprocessing.connection._exhaustive_wait: `&` used instead of `and` when filtering ready handles on Windows · Issue #156070 · python/cpython
X Title: multiprocessing.connection._exhaustive_wait: `&` used instead of `and` when filtering ready handles on Windows · Issue #156070 · python/cpython
Description: Bug report Bug description: In Lib/multiprocessing/connection.py, the Windows branch of _exhaustive_wait() that handles more than 60 handles (added in gh-89240 / GH-107873) filters the already signalled handles out of the list with if re...
Open Graph Description: Bug report Bug description: In Lib/multiprocessing/connection.py, the Windows branch of _exhaustive_wait() that handles more than 60 handles (added in gh-89240 / GH-107873) filters the already sign...
X Description: Bug report Bug description: In Lib/multiprocessing/connection.py, the Windows branch of _exhaustive_wait() that handles more than 60 handles (added in gh-89240 / GH-107873) filters the already sign...
Opengraph URL: https://github.com/python/cpython/issues/156070
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"multiprocessing.connection._exhaustive_wait: `&` used instead of `and` when filtering ready handles on Windows","articleBody":"# Bug report\n\n### Bug description:\n\nIn `Lib/multiprocessing/connection.py`, the Windows branch of `_exhaustive_wait()` that handles more than 60 handles (added in gh-89240 / GH-107873) filters the already signalled handles out of the list with\n\n```python\n if res:\n L = [h for i, h in enumerate(L) if i > res[0] & i not in res]\n```\n\n`&` binds tighter than the comparison operators, so this parses as the chained comparison `i > (res[0] & i) not in res`, i.e. `i > (res[0] & i) and ((res[0] & i) not in res)`, which is not the intended `i > res[0] and i not in res`. For example with `res = [2, 5]` and eight handles it keeps indexes `1, 4, 5` instead of `3, 4, 6, 7`, so signalled handles can stay in `L` (and be waited on and reported again) while unsignalled ones are dropped.\n\n```python\n>>> res = [2, 5]; L = list(\"abcdefgh\")\n>>> [h for i, h in enumerate(L) if i > res[0] & i not in res]\n['b', 'e', 'f']\n>>> [h for i, h in enumerate(L) if i > res[0] and i not in res]\n['d', 'e', 'g', 'h']\n```\n\npylint reports the line as `bad-chained-comparison` (\"suspicious 2-part chained comparison using semantically incompatible operators ('>' and 'not in')\"), which is how I found it. The fix is to use `and`.\n\n### CPython versions tested on:\n\nCPython main branch, 3.14\n\n### Operating systems tested on:\n\nWindows (code path), found on macOS by static analysis\n\n\u003c!-- gh-linked-prs -->\n* gh-156071\n\u003c!-- /gh-linked-prs -->","author":{"url":"https://github.com/ekanshul","@type":"Person","name":"ekanshul"},"datePublished":"2026-08-19T21:00:03Z","url":"https://github.com/python/cpython/issues/156070"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:25204b56-15d0-3554-6980-3735e1467130 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A620:19B6A2:1B4B7BA:2406D49:6B021E22 |
| html-safe-nonce | ccdb26780cbc1f6954a7ddd624db963f1eabfe2916daf445c8d7a0ede66e2ef8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjIwOjE5QjZBMjoxQjRCN0JBOjI0MDZENDk6NkIwMjFFMjIiLCJ2aXNpdG9yX2lkIjoiMzE5NzEwMTYwODg2MTMxMDQ5OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8c9eb9103947cc58edab371aa4e1c2619cd1f421f7ca859d8b83a3b3bed9c216 |
| hovercard-subject-tag | issue:5197096998 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/156070/issue_layout |
| twitter:image | https://opengraph.githubassets.com/036e49d6f492732057070e3f0893d9116995f736041bd8affe1278596115dcb9/python/cpython/issues/156070 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/036e49d6f492732057070e3f0893d9116995f736041bd8affe1278596115dcb9/python/cpython/issues/156070 |
| og:image:alt | Bug report Bug description: In Lib/multiprocessing/connection.py, the Windows branch of _exhaustive_wait() that handles more than 60 handles (added in gh-89240 / GH-107873) filters the already sign... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ekanshul |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width