gh-145587: fix busy loop in multiprocessing.connection.wait on Windows#145597
gh-145587: fix busy loop in multiprocessing.connection.wait on Windows#145597Shrey-N wants to merge 10 commits intopython:mainfrom
Conversation
…Windows Ensure wait() blocks for the specified timeout when object_list is empty, preventing 100% CPU usage. This aligns the Windows behavior with the Unix implementation.
|
I think we should add a test to check if |
Co-authored-by: AN Long <aisk@users.noreply.github.com>
|
I have removed the unnecessary line and added the test as requested @chris-eibl @aisk |
|
yup just did that @chris-eibl :) |
|
@chris-eibl I believe the CI failure is an unrelated UnboundLocalError issue in the main branch. My tests are now passing. Could you please restart the checks, maybe that fixes it... Thank you for your patience :) |
There was a problem hiding this comment.
Thanks @Shrey-N.
The failing test_ci_fuzz_stdlib
======================================================================
ERROR: test_ci_fuzz_stdlib (test.test_tools.test_compute_changes.TestProcessChangedFiles.test_ci_fuzz_stdlib) (p=PosixPath('Modules/tomllib'))
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_tools/test_compute_changes.py", line 57, in test_ci_fuzz_stdlib
result = process_changed_files({f})
^
UnboundLocalError: cannot access local variable 'f' where it is not associated with a value
seems uncorrelated to me as well and maybe relates to #145232 @StanFromIreland?
|
Thanks, I'll look into it. |
|
Why did it fail now 😭 |
|
There is |
|
Thank you for the explanation on the failure @chris-eibl! And thank you both for the approvals :) |
On Windows,
multiprocessing.connection.waitreturns immediately if theobject_listis empty, regardless of the timeout.This fix adds a check to make sure the function actually sleeps for the duration of the timeout, matching the Unix behavior and stopping the 100% CPU usage spike.
Verified locally:-
Fixes #145587