Skip to content

Commit 836b281

Browse files
authored
gh-136186: Fix more flaky tests in test_external_inspection (#143235)
1 parent 5225635 commit 836b281

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Lib/test/test_external_inspection.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,12 @@ def main_work():
17521752
unwinder_gil = RemoteUnwinder(
17531753
p.pid, only_active_thread=True
17541754
)
1755-
gil_traces = _get_stack_trace_with_retry(unwinder_gil)
1755+
# Use condition to retry until we capture a thread holding the GIL
1756+
# (sampling may catch moments with no GIL holder on slow CI)
1757+
gil_traces = _get_stack_trace_with_retry(
1758+
unwinder_gil,
1759+
condition=lambda t: sum(len(i.threads) for i in t) >= 1,
1760+
)
17561761

17571762
# Count threads
17581763
total_threads = sum(

0 commit comments

Comments
 (0)