Skip to content

Commit 08f98f4

Browse files
Fix intermittent failures for the PyUnstable_Object_EnableDeferredRefcount tests (GH-126849)
Hotfix for the PyUnstable_Object_EnableDeferredRefcount tests.
1 parent d00f7b1 commit 08f98f4

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

Lib/test/test_capi/test_object.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ def test_ClearWeakRefsNoCallbacks_no_weakref_support(self):
134134
_testcapi.pyobject_clear_weakrefs_no_callbacks(obj)
135135

136136

137+
@threading_helper.requires_working_threading()
137138
class EnableDeferredRefcountingTest(unittest.TestCase):
138139
"""Test PyUnstable_Object_EnableDeferredRefcount"""
139140
@support.requires_resource("cpu")
@@ -158,21 +159,13 @@ def silly_func(obj):
158159

159160
silly_list = [1, 2, 3]
160161
threads = [
161-
Thread(target=silly_func, args=(silly_list,)) for _ in range(5)
162+
Thread(target=silly_func, args=(silly_list,)) for _ in range(4)
162163
]
163164

164-
with threading_helper.catch_threading_exception() as cm:
165-
for t in threads:
166-
t.start()
167-
165+
with threading_helper.start_threads(threads):
168166
for i in range(10):
169167
silly_list.append(i)
170168

171-
for t in threads:
172-
t.join()
173-
174-
self.assertIsNone(cm.exc_value)
175-
176169
if support.Py_GIL_DISABLED:
177170
self.assertTrue(_testinternalcapi.has_deferred_refcount(silly_list))
178171

0 commit comments

Comments
 (0)