From 2bd561d20e3cc44652f5fc3cf2302c8c771de6c9 Mon Sep 17 00:00:00 2001 From: Diego Russo Date: Thu, 13 Mar 2025 11:08:17 +0000 Subject: [PATCH 1/2] [3.11] gh-106883: Increase timeout for a test_sys test On some platforms the test test_current_frames_exceptions_deadlock goes in timeout when CPython is built with debug. The execution time of the test is about 4x and the current timeout is not enough to complete the test. --- Lib/test/test_sys.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 28931039f3792e..92ef6165f01e7b 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -518,10 +518,12 @@ def thread_function(num_objects): NUM_OBJECTS = 1000 NUM_THREADS = 10 - # 40 seconds should be enough for the test to be executed: if it - # is more than 40 seconds it means that the process is in deadlock - # hence the test fails - TIMEOUT = 40 + # 160 seconds should be enough for the test to be executed: if it + # is more than 160 seconds it means that the process is in deadlock + # hence the test fails. + # The timeout is high because on older platforms it takes some time + # for the test to be executed when CPython is built with debug flags. + TIMEOUT = 160 # Test the sys._current_frames and sys._current_exceptions calls pid = os.fork() From abf4144ca6800c8fd0db75e82bd7999f8fcf6048 Mon Sep 17 00:00:00 2001 From: Diego Russo Date: Thu, 13 Mar 2025 14:57:35 +0000 Subject: [PATCH 2/2] Address feedback --- Lib/test/test_sys.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 92ef6165f01e7b..3f65d5e62fc5d4 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -477,6 +477,7 @@ def g456(): @threading_helper.reap_threads @threading_helper.requires_working_threading() @support.requires_fork() + @support.requires_resource('cpu') def test_current_frames_exceptions_deadlock(self): """ Reproduce the bug raised in GH-106883 and GH-116969. @@ -515,21 +516,14 @@ def thread_function(num_objects): # The number of objects should be big enough to increase the # chances to call the GC. - NUM_OBJECTS = 1000 - NUM_THREADS = 10 - - # 160 seconds should be enough for the test to be executed: if it - # is more than 160 seconds it means that the process is in deadlock - # hence the test fails. - # The timeout is high because on older platforms it takes some time - # for the test to be executed when CPython is built with debug flags. - TIMEOUT = 160 + NUM_OBJECTS = 100 + NUM_THREADS = 2 # Test the sys._current_frames and sys._current_exceptions calls pid = os.fork() if pid: # parent process try: - support.wait_process(pid, exitcode=0, timeout=TIMEOUT) + support.wait_process(pid, exitcode=0, timeout=support.SHORT_TIMEOUT) except KeyboardInterrupt: # When pressing CTRL-C kill the deadlocked process os.kill(pid, signal.SIGTERM)