Skip to content

Commit 0f17e0b

Browse files
committed
gh-150387: Fix hang in test_run_failed_script_live on slow buildbots
The test relied on the failing script (``1/0``) crashing fast enough that fewer than ``MIN_SAMPLES_FOR_TUI`` (200) samples were collected, which would trigger the early-return path in ``sample.sample_live`` and bypass the TUI input loop. On slow buildbots (ASan, TraceRefs, NoGIL) the interpreter takes long enough to bootstrap and reach the ``1/0`` that the profiler easily collects >=200 samples, pushing execution into the ``while collector.running:`` loop. Because the mock only queued a final ``q`` keystroke when ``n_times >= 500`` (and the failed-script test used ``n_times=200``), nothing ever set ``running`` to ``False`` and the test hung until the regrtest timeout. Always queue the final ``q`` so the live TUI loop exits regardless of how many samples were collected.
1 parent 0851700 commit 0f17e0b

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

Lib/test/test_profiling/test_sampling_profiler/test_live_collector_ui.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,8 +835,7 @@ def mock_init_curses_side_effect(self, n_times, mock_self, stdscr):
835835
# still failing
836836
for _ in range(n_times):
837837
mock_self.display.simulate_input(-1)
838-
if n_times >= 500:
839-
mock_self.display.simulate_input(ord('q'))
838+
mock_self.display.simulate_input(ord('q'))
840839

841840
def test_run_failed_module_live(self):
842841
"""Test that running a existing module that fails exits with clean error."""
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Fix hang in
2+
``test.test_profiling.test_sampling_profiler.test_live_collector_ui.TestLiveModeErrors.test_run_failed_script_live``
3+
on slow buildbots. The test now always queues a final ``q`` keystroke so the
4+
live TUI loop exits even when the profiler collects enough samples to enter
5+
the post-finished input loop.

0 commit comments

Comments
 (0)