Repository navigation
test_multiprocessing_spawn.test_processes flaky tests on Windows #130733
Description
Activity
- addedtestsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Mar 1, 2025 - changed the title
[-]`test_async_error_callback` test flaky in `test_multiprocessing_spawn.test_processes`[/-][+]`test_multiprocessing_spawn.test_processes` flaky tests on Windows[/+]on Mar 24, 2025 - marked flaky
test_tracebackon free-threaded Windows (x86) #131685 as a duplicate of this issueon Mar 24, 2025 The Windows implementation of PipeConnection doesn't support concurrent calls:
cpython/Lib/multiprocessing/connection.py
Lines 291 to 294 in 7c3692f
if self._send_ov is not None: # A connection should only be used by a single thread raise ValueError("concurrent send_bytes() calls " "are not supported") (Added by @vstinner in #109244)
But multiprocessing's
SimpleQueuehas always skipped locking because "writes to a message oriented win32 pipe are atomic":cpython/Lib/multiprocessing/queues.py
Lines 392 to 394 in 7c3692f
if self._wlock is None: # writes to a message oriented win32 pipe are atomic self._writer.send_bytes(obj) My guess is that we need at least a
threading.Lock()forself._wlockinSimpleQueueon Windows. I'm not sure we need an inter-process multiprocessing lock.Reacted by Olivier GriselIf the underlying write is atomic (which I believe is true, but would have to double-check), then a simple lock around the code that sets and clears
_send_ovwould seem to be all that's needed, yeah.The Windows implementation of PipeConnection doesn't support concurrent calls
In #109244, my main need was to be able to cancel an on-going write by calling
ov.cancel()inclose(). For that, I added a newself._send_ovattribute to share the overlapped operation between_send_bytes()andclose(). If you need/want to support multiple "concurrent" writes, you should replaceself._send_ovattribute with alistof overlapped operations.FYI we are seeing this issue from time to time in the scikit-learn CI, see scikit-learn/scikit-learn#30810 for more details.
Not sure it helps much, but lately in the scikit-learn CI, we have seen this error mostly on Windows arm. It happened 9 times on our daily wheels run since November 21 and 8 out of 9 was on Windows arm, 1 out of 9 was on Windows amd, see scikit-learn/scikit-learn#30810 (comment) for the current summary.
- added a commit that references this issue
on Oct 5, 2026
Bug report
Seen on Windows free threading build, but not free threading specific:
https://github.com/python/cpython/actions/runs/13606907022/job/38039459160?pr=130732
This is in Windows specific code. Not yet sure if this is free threading specific.
Also `test_traceback`: