https://github.com/python/cpython/commit/ea0ee925ad755999d6095ba61de2652ec9275f04
commit: ea0ee925ad755999d6095ba61de2652ec9275f04
branch: main
author: Christian Aurich Zanettini Martins <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-10-06T15:12:15Z
summary:

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.

files:
M Lib/idlelib/idle_test/test_run.py

diff --git a/Lib/idlelib/idle_test/test_run.py 
b/Lib/idlelib/idle_test/test_run.py
index d7e69f70fd87d85..b106fd7be78b0b1 100644
--- a/Lib/idlelib/idle_test/test_run.py
+++ b/Lib/idlelib/idle_test/test_run.py
@@ -546,9 +546,11 @@ def test_interrupt_blocking_call(self):
         # gh-74112: interrupt the main thread blocked in time.sleep().
         timer = threading.Timer(0.1, self.ex.interrupt_the_server)
         self.addCleanup(timer.join)
-        timer.start()
         start = time.monotonic()
         with self.assertRaises(KeyboardInterrupt):
+            # On a loaded machine the signal can arrive before the main
+            # thread reaches time.sleep(), so start the timer in the block.
+            timer.start()
             time.sleep(support.SHORT_TIMEOUT)
         self.assertLess(time.monotonic() - start, support.SHORT_TIMEOUT / 2)
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to