Repository navigation
test_interrupt flaky in free-threading interpreters - #12730
Merged
Merged
Conversation
Contributor
Unit Test ResultsSee test report for an extended history of previous test failures. This is useful for diagnosing flaky tests. 29 files ±0 29 suites ±0 6h 9m 53s ⏱️ - 30m 24s Results for commit 4d70ca9. ± Comparison against base commit 025d6ac. |
`test_threaded.py::test_interrupt` flakes on free-threaded CPython: the test hangs for the full pytest-timeout budget inside `ThreadPoolExecutor.__exit__` -> `shutdown(wait=True)` -> `Thread.join()`. Root cause is python/cpython#148874 (still open, and labelled for both 3.14 and 3.15): since 3.14 `with X:` compiles to `LOAD_SPECIAL __enter__; CALL`, and `CALL` ends with `_CHECK_PERIODIC_AT_END`, which runs signal handlers. If the handler raises, `frame->instr_ptr` still points at `CALL`, i.e. at an offset that the with-statement's exception table does not cover, so `__exit__` never runs and whatever `__enter__` acquired is leaked forever - a `threading.Lock`, a `queue.Queue` mutex, or `concurrent.futures.Future._condition`. Free-threaded builds run the eval breaker far more eagerly than GIL ones, so a single Ctrl+C has a realistic chance of landing in that window. When it does, a worker thread ends up blocked forever on the leaked lock, and joining it in `shutdown()` wedges the whole pytest session. Reproduced locally (~1 leaked lock per 1700 signalled `with lock:` acquisitions on 3.14t, hangs within a few hundred to a few thousand iterations of the previous test body on both 3.14t and 3.15t). Dask cannot fix this: the leaked locks belong to `concurrent.futures` and to the interpreter. Move the workload to a subprocess so that a leaked lock can only take down the child, and exit the child with `os._exit()` so that its cleanup cannot hang either. The test still asserts that `get()` raises `KeyboardInterrupt` instead of waiting for the running tasks.
test_interrupt flaky in free-threading interpreters
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.
#12437 identified
test_interrupt[True]to be flaky in Python 3.14t due to python/cpython#150873test_interrupt[False]also hangs in free-threading interpreters due to python/cpython#148874