summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_capi
diff options
context:
space:
mode:
authorPeter Bierma <zintensitydev@gmail.com>2024-11-15 13:03:46 (GMT)
committerGitHub <noreply@github.com>2024-11-15 13:03:46 (GMT)
commit08f98f4576f95f9ae1a4423d151fce053416f39f (patch)
tree2d09ded76859d2a93e51a1aad7547d292d0a0c51 /Lib/test/test_capi
parentd00f7b1b9d12dd6f29d7616217900785c4f6674d (diff)
downloadcpython-08f98f4576f95f9ae1a4423d151fce053416f39f.zip
cpython-08f98f4576f95f9ae1a4423d151fce053416f39f.tar.gz
cpython-08f98f4576f95f9ae1a4423d151fce053416f39f.tar.bz2
Fix intermittent failures for the `PyUnstable_Object_EnableDeferredRefcount` tests (GH-126849)
Hotfix for the PyUnstable_Object_EnableDeferredRefcount tests.
Diffstat (limited to 'Lib/test/test_capi')
-rw-r--r--Lib/test/test_capi/test_object.py13
1 files changed, 3 insertions, 10 deletions
diff --git a/Lib/test/test_capi/test_object.py b/Lib/test/test_capi/test_object.py
index a38b203..b0d3993 100644
--- a/Lib/test/test_capi/test_object.py
+++ b/Lib/test/test_capi/test_object.py
@@ -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))