]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-136186: Fix more flaky tests in test_external_inspection (#143235)
authorPablo Galindo Salgado <Pablogsal@gmail.com>
Sun, 28 Dec 2025 12:52:32 +0000 (12:52 +0000)
committerGitHub <noreply@github.com>
Sun, 28 Dec 2025 12:52:32 +0000 (12:52 +0000)
Lib/test/test_external_inspection.py

index b1a3a8e65a98020b7710364b4afc713c840713b1..fe1b5fbe00bbc4650dfb29d8190d4264f0441984 100644 (file)
@@ -1752,7 +1752,12 @@ class TestGetStackTrace(RemoteInspectionTestBase):
                     unwinder_gil = RemoteUnwinder(
                         p.pid, only_active_thread=True
                     )
-                    gil_traces = _get_stack_trace_with_retry(unwinder_gil)
+                    # Use condition to retry until we capture a thread holding the GIL
+                    # (sampling may catch moments with no GIL holder on slow CI)
+                    gil_traces = _get_stack_trace_with_retry(
+                        unwinder_gil,
+                        condition=lambda t: sum(len(i.threads) for i in t) >= 1,
+                    )
 
                     # Count threads
                     total_threads = sum(