]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix intermittent failures for the `PyUnstable_Object_EnableDeferredRefcount` tests...
authorPeter Bierma <zintensitydev@gmail.com>
Fri, 15 Nov 2024 13:03:46 +0000 (08:03 -0500)
committerGitHub <noreply@github.com>
Fri, 15 Nov 2024 13:03:46 +0000 (14:03 +0100)
Hotfix for the PyUnstable_Object_EnableDeferredRefcount tests.

Lib/test/test_capi/test_object.py

index a38b203ed12fa27a6e756200e3ebcde44f342a9d..b0d39937fd865f0d278acc3bb84c56733a1af584 100644 (file)
@@ -134,6 +134,7 @@ class ClearWeakRefsNoCallbacksTest(unittest.TestCase):
         _testcapi.pyobject_clear_weakrefs_no_callbacks(obj)
 
 
+@threading_helper.requires_working_threading()
 class EnableDeferredRefcountingTest(unittest.TestCase):
     """Test PyUnstable_Object_EnableDeferredRefcount"""
     @support.requires_resource("cpu")
@@ -158,21 +159,13 @@ class EnableDeferredRefcountingTest(unittest.TestCase):
 
         silly_list = [1, 2, 3]
         threads = [
-            Thread(target=silly_func, args=(silly_list,)) for _ in range(5)
+            Thread(target=silly_func, args=(silly_list,)) for _ in range(4)
         ]
 
-        with threading_helper.catch_threading_exception() as cm:
-            for t in threads:
-                t.start()
-
+        with threading_helper.start_threads(threads):
             for i in range(10):
                 silly_list.append(i)
 
-            for t in threads:
-                t.join()
-
-            self.assertIsNone(cm.exc_value)
-
         if support.Py_GIL_DISABLED:
             self.assertTrue(_testinternalcapi.has_deferred_refcount(silly_list))