Skip to content

Commit c73527f

Browse files
christianaurichzmserhiy-storchaka
authored andcommitted
gh-74112: Fix race in test_interrupt_blocking_call (GH-158914)
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)
1 parent a089060 commit c73527f

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
@@ -540,9 +540,11 @@ def test_interrupt_blocking_call(self):
540540
# gh-74112: interrupt the main thread blocked in time.sleep().
541541
timer = threading.Timer(0.1, self.ex.interrupt_the_server)
542542
self.addCleanup(timer.join)
543-
timer.start()
544543
start = time.monotonic()
545544
with self.assertRaises(KeyboardInterrupt):
545+
# On a loaded machine the signal can arrive before the main
546+
# thread reaches time.sleep(), so start the timer in the block.
547+
timer.start()
546548
time.sleep(support.SHORT_TIMEOUT)
547549
self.assertLess(time.monotonic() - start, support.SHORT_TIMEOUT / 2)
548550

0 commit comments

Comments
 (0)