mirror of https://github.com/python/cpython.git
Fix intermittent failures for the `PyUnstable_Object_EnableDeferredRefcount` tests (GH-126849)
Hotfix for the PyUnstable_Object_EnableDeferredRefcount tests.
This commit is contained in:
parent
d00f7b1b9d
commit
08f98f4576
|
@ -134,6 +134,7 @@ def test_ClearWeakRefsNoCallbacks_no_weakref_support(self):
|
||||||
_testcapi.pyobject_clear_weakrefs_no_callbacks(obj)
|
_testcapi.pyobject_clear_weakrefs_no_callbacks(obj)
|
||||||
|
|
||||||
|
|
||||||
|
@threading_helper.requires_working_threading()
|
||||||
class EnableDeferredRefcountingTest(unittest.TestCase):
|
class EnableDeferredRefcountingTest(unittest.TestCase):
|
||||||
"""Test PyUnstable_Object_EnableDeferredRefcount"""
|
"""Test PyUnstable_Object_EnableDeferredRefcount"""
|
||||||
@support.requires_resource("cpu")
|
@support.requires_resource("cpu")
|
||||||
|
@ -158,21 +159,13 @@ def silly_func(obj):
|
||||||
|
|
||||||
silly_list = [1, 2, 3]
|
silly_list = [1, 2, 3]
|
||||||
threads = [
|
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:
|
with threading_helper.start_threads(threads):
|
||||||
for t in threads:
|
|
||||||
t.start()
|
|
||||||
|
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
silly_list.append(i)
|
silly_list.append(i)
|
||||||
|
|
||||||
for t in threads:
|
|
||||||
t.join()
|
|
||||||
|
|
||||||
self.assertIsNone(cm.exc_value)
|
|
||||||
|
|
||||||
if support.Py_GIL_DISABLED:
|
if support.Py_GIL_DISABLED:
|
||||||
self.assertTrue(_testinternalcapi.has_deferred_refcount(silly_list))
|
self.assertTrue(_testinternalcapi.has_deferred_refcount(silly_list))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue