Repository navigation
tests: raise the test_gil_scoped timeout on Windows free-threaded - #6321
Merged
Merged
Conversation
On free-threaded CPython, a blocking acquire of a held PyMutex calls SwitchToThread() up to 40 times before it parks. When other processes use the CPU, each Thread.start() can take seconds, and the 10 s subprocess timeout reported a deadlock that did not exist. Assisted-by: ClaudeCode:claude-fable-5-2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
Description
The rare
test_gil_scoped.py"DEADLOCK" failure onwindows-latest, 3.14t(logging added in #6293) is not a deadlock. The child process is slow, not blocked.On free-threaded CPython, a blocking acquire of a held
PyMutexcalls_Py_yield()(SwitchToThread()on Windows) up to 40 times before it parks (_PyMutex_LockTimedinPython/lock.c).Thread.start()waits on such a lock. When other processes use the CPU, each start takes about 0.35 s on a GitHub Windows runner, where a GIL build takes about 0.03 s. In CI, the CMake build that runs in parallel with pytest supplies the load. Native stacks from a stress job show the main thread in_Py_yieldfrom_PyMutex_LockTimed, with the GIL disabled and no stop-the-world request.This PR raises the default subprocess timeout from 10 s to 60 s on Windows free-threaded builds only.
Results from a stress job on a Windows runner with four busy processes, sequential 8-thread cases:
Without the busy processes, there were 0 failures in 538,000 runs with the 10 s timeout.