GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||
GeezerVison is showing github.com — test_concurrent_gi_frame is flaky under --parallel-threads: the reader thread may never run its loop body · Issue #161489 · python/cpython Open Labels testsTests in the Lib/test dirTests in the Lib/test dirtopic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionBug reportBug description:
ReproducerOn a 5 out of 10 runs reproduced, after 126 s, 160 s, 320 s, 368 s and 391 s. Build: GCC 15.2.0, 10 cores. Not sensitive to mimalloc purge settings (2/5 with Cause
def reader(): while not done.is_set(): # already True on first evaluation frame = g.gi_frame ... frames.add(frame) self.assertIsNone(g.gi_frame) threading_helper.run_concurrently([runner, reader]) self.assertEqual(len(frames), 1) # 0 != 1 This rules out the alternative reading, which would have been a real bug: Why
|
| Condition | Method executions | frames empty |
min. loop iterations |
|---|---|---|---|
| 1 copy, 1 process | 300 | 0 | 271 |
| 1 copy, 24 processes | 1440 | 0 | 196 |
| 4 copies, 1 process | 800 | 0 | 67 |
| 4 copies × 10 processes | 1600 | 3 | 0 |
All three captured cases were (len=0, iterations=0, non_none=0), matching the instrumented run. Note the last column decreasing monotonically with load until it reaches zero: the same phenomenon at increasing scale.
--parallel-threads=4 is the configuration used in .github/workflows/reusable-san.yml (--tsan-parallel --parallel-threads=4), so this is a plausible source of intermittent CI failures.
The assertion the test appears to care about — that the reader never observes two distinct frame objects, per gh-144446 — held in every run I saw (frames > 1 never occurred in the 2400 executions where I tracked it). len(frames) == 1 additionally requires the reader to be scheduled, which is not guaranteed. I have no opinion on which way to resolve that, since tolerating zero and synchronising to guarantee one iteration cover different things.
Test added in #156037 for gh-144446; present since v3.16.0a1.
CPython main branch
Linux
pythongh-161489: Ensure reader inspects a live generator in concurren…