https://github.com/python/cpython/commit/5daeebbbf2533bbb56f1cc95fa6db9c5efcb5dc5
commit: 5daeebbbf2533bbb56f1cc95fa6db9c5efcb5dc5
branch: 3.13
author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com>
committer: serhiy-storchaka <storch...@gmail.com>
date: 2025-05-04T19:18:49Z
summary:

[3.13] gh-109700: Improve stress tests for interpreter creation (GH-109946) 
(GH-133391)

* Ensure that destructors are called in the test that created interpreters, not 
after finishing it.
* Try to create/run interpreters in threads simultaneously.
* Mark tests that requires over 6GB of memory with bigmemtest.
(cherry picked from commit 61b50a98b42a75a66ec52d78811b32e70220bcaf)

Co-authored-by: Serhiy Storchaka <storch...@gmail.com>

files:
M Lib/test/test_interpreters/test_stress.py

diff --git a/Lib/test/test_interpreters/test_stress.py 
b/Lib/test/test_interpreters/test_stress.py
index 56bfc1721992c8..fae2f38cb5534b 100644
--- a/Lib/test/test_interpreters/test_stress.py
+++ b/Lib/test/test_interpreters/test_stress.py
@@ -21,21 +21,29 @@ def test_create_many_sequential(self):
         for _ in range(100):
             interp = interpreters.create()
             alive.append(interp)
+        del alive
+        support.gc_collect()
 
-    @support.requires_resource('cpu')
-    @threading_helper.requires_working_threading()
-    def test_create_many_threaded(self):
+    @support.bigmemtest(size=200, memuse=32*2**20, dry_run=False)
+    def test_create_many_threaded(self, size):
         alive = []
+        start = threading.Event()
         def task():
+            # try to create all interpreters simultaneously
+            if not start.wait(support.SHORT_TIMEOUT):
+                raise TimeoutError
             interp = interpreters.create()
             alive.append(interp)
-        threads = (threading.Thread(target=task) for _ in range(200))
+        threads = [threading.Thread(target=task) for _ in range(size)]
         with threading_helper.start_threads(threads):
-            pass
+            start.set()
+        del alive
+        support.gc_collect()
 
-    @support.requires_resource('cpu')
     @threading_helper.requires_working_threading()
-    def test_many_threads_running_interp_in_other_interp(self):
+    @support.bigmemtest(size=200, memuse=34*2**20, dry_run=False)
+    def test_many_threads_running_interp_in_other_interp(self, size):
+        start = threading.Event()
         interp = interpreters.create()
 
         script = f"""if True:
@@ -47,6 +55,9 @@ def run():
             interp = interpreters.create()
             alreadyrunning = (f'{interpreters.InterpreterError}: '
                               'interpreter already running')
+            # try to run all interpreters simultaneously
+            if not start.wait(support.SHORT_TIMEOUT):
+                raise TimeoutError
             success = False
             while not success:
                 try:
@@ -58,9 +69,10 @@ def run():
                 else:
                     success = True
 
-        threads = (threading.Thread(target=run) for _ in range(200))
+        threads = [threading.Thread(target=run) for _ in range(size)]
         with threading_helper.start_threads(threads):
-            pass
+            start.set()
+        support.gc_collect()
 
 
 if __name__ == '__main__':

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to