Skip to content

Commit 1581464

Browse files
ekanshulclaude
andcommitted
Fix the regression test's wait timeout and signalled indices
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent d30221e commit 1581464

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

Lib/test/_test_multiprocessing.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5923,18 +5923,23 @@ def test_exhaustive_wait_more_than_60_handles(self):
59235923
import _winapi
59245924
from multiprocessing.connection import _exhaustive_wait
59255925

5926-
# More than 60 handles takes the batched path.
5926+
# More than 60 handles takes the batched path. Manual reset events
5927+
# stay signalled, so the handles the batched wait already reported
5928+
# must be dropped from the list that is scanned afterwards.
59275929
events = [_winapi.CreateEventW(0, True, False, None)
59285930
for _ in range(70)]
59295931
self.addCleanup(lambda: [_winapi.CloseHandle(e) for e in events])
59305932

5931-
# Spread the signalled events out so they do not all land in the
5932-
# first batch, and leave index 0 unsignalled.
5933-
chosen = [3, 17, 42, 68]
5933+
# BatchedWaitForMultipleObjects reports the lowest signalled handle
5934+
# of each 63 handle batch, so signalling the first event pins the
5935+
# first reported index at 0 and spreads the rest over both batches.
5936+
chosen = [0, 17, 42, 68]
59345937
for i in chosen:
59355938
_winapi.SetEvent(events[i])
59365939

5937-
ready = _exhaustive_wait(events, 0)
5940+
# A zero timeout is not usable here: the batched wait would report a
5941+
# timeout before its worker threads have run.
5942+
ready = _exhaustive_wait(events, 10_000)
59385943
self.assertEqual(sorted(ready), sorted(events[i] for i in chosen))
59395944

59405945
#

0 commit comments

Comments
 (0)