You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
multiprocessing.connection.wait high CPU load with empty object_list #145587
Hiya @danielhrisca I have verified this issue with a script on Windows.
The issue is in Lib/multiprocessing/connection.py,
While the Unix implementation uses selectors.select, the Windows version attempts to build a handle list. If that list is empty, it returns an empty result immediately without ever hitting a blocking call.
I am submitting a PR in a minute that adds a check for an empty object_list to ensure the function properly respects the timeout before returning.
Reproduction Script:-
from multiprocessing.connection import wait
import time
start = time.time()
# This should take approx 1 second, but returns instantly on Windows
wait([], 1.0)
print(f"Elapsed: {time.time() - start:.4f}s")
Activity
danielhrisca commentedon Mar 6, 2026
I've also tested with Python 3.12.3 on Linux and there the CPU load is very low with an empty object_list
YvesDup commentedon Mar 6, 2026
Could you provide a runnable and complete example, please ?
danielhrisca commentedon Mar 6, 2026
I've updated the example. The CPU load is high even without the print statement
If I run it on Linux I see that the
waitcall takes in the order of msThe same example when running on Windows produces this output
pythongh-145587: fix busy loop in multiprocessing.connection.wait on …
Shrey-N commentedon Mar 6, 2026
Hiya @danielhrisca I have verified this issue with a script on Windows.
The issue is in
Lib/multiprocessing/connection.py,While the Unix implementation uses
selectors.select, the Windows version attempts to build a handle list. If that list is empty, it returns an empty result immediately without ever hitting a blocking call.I am submitting a PR in a minute that adds a check for an empty object_list to ensure the function properly respects the timeout before returning.
Reproduction Script:-
Hope the PR, and explanation helps :)
pythongh-145587: fix busy loop in multiprocessing.connection.wait on …
gh-145587: fix busy loop in multiprocessing.connection.wait on Windows (
pythongh-145587: fix busy loop in multiprocessing.connection.wait on …