Skip to content

Commit 4ff9834

Browse files
committed
gh-145587: fix busy loop in multiprocessing.connection.wait on 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.
1 parent c3fb0d9 commit 4ff9834

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Lib/multiprocessing/connection.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,14 @@ def wait(object_list, timeout=None):
10851085
10861086
Returns list of those objects in object_list which are ready/readable.
10871087
'''
1088+
if not object_list:
1089+
if timeout is None:
1090+
while True:
1091+
time.sleep(1e6)
1092+
elif timeout > 0:
1093+
time.sleep(timeout)
1094+
return []
1095+
10881096
if timeout is None:
10891097
timeout = INFINITE
10901098
elif timeout < 0:

0 commit comments

Comments
 (0)