Skip to content

Commit 2d4d26d

Browse files
[3.14] gh-74112: Fix race in test_interrupt_blocking_call (GH-158914) (GH-158920)
On a loaded machine the KeyboardInterrupt could be raised before the main thread reached time.sleep(), escape the test and stop the whole regrtest run. (cherry picked from commit ea0ee92) Co-authored-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
1 parent 18ef0f0 commit 2d4d26d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎Lib/idlelib/idle_test/test_run.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,11 @@ def test_interrupt_blocking_call(self):
546546
# gh-74112: interrupt the main thread blocked in time.sleep().
547547
timer = threading.Timer(0.1, self.ex.interrupt_the_server)
548548
self.addCleanup(timer.join)
549-
timer.start()
550549
start = time.monotonic()
551550
with self.assertRaises(KeyboardInterrupt):
551+
# On a loaded machine the signal can arrive before the main
552+
# thread reaches time.sleep(), so start the timer in the block.
553+
timer.start()
552554
time.sleep(support.SHORT_TIMEOUT)
553555
self.assertLess(time.monotonic() - start, support.SHORT_TIMEOUT / 2)
554556

0 commit comments

Comments
 (0)