Skip to content

Commit 1ea8107

Browse files
committed
Reduce iteration count instead of skipping tests
1 parent 8f18671 commit 1ea8107

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

Lib/test/test_weakref.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,6 @@ def collect():
101101
t.join()
102102

103103

104-
skip_if_tsan_and_gil_disabled = unittest.skipIf(
105-
support.check_sanitizer(thread=True) and support.Py_GIL_DISABLED,
106-
"Test is prohibitively slow with TSAN enabled and the GIL disabled")
107-
108-
109104
class ReferencesTestCase(TestBase):
110105

111106
def test_basic_ref(self):
@@ -1260,6 +1255,12 @@ class MappingTestCase(TestBase):
12601255

12611256
COUNT = 10
12621257

1258+
if support.check_sanitizer(thread=True) and support.Py_GIL_DISABLED:
1259+
# Reduce iteration count to get acceptable latency
1260+
NUM_THREADED_ITERATIONS = 1000
1261+
else:
1262+
NUM_THREADED_ITERATIONS = 100000
1263+
12631264
def check_len_cycles(self, dict_type, cons):
12641265
N = 20
12651266
items = [RefCycle() for i in range(N)]
@@ -1882,33 +1883,30 @@ def test_make_weak_keyed_dict_repr(self):
18821883
self.assertRegex(repr(dict), '<WeakKeyDictionary at 0x.*>')
18831884

18841885
@threading_helper.requires_working_threading()
1885-
@skip_if_tsan_and_gil_disabled
18861886
def test_threaded_weak_valued_setdefault(self):
18871887
d = weakref.WeakValueDictionary()
18881888
with collect_in_thread():
1889-
for i in range(100000):
1889+
for i in range(self.NUM_THREADED_ITERATIONS):
18901890
x = d.setdefault(10, RefCycle())
18911891
self.assertIsNot(x, None) # we never put None in there!
18921892
del x
18931893

18941894
@threading_helper.requires_working_threading()
1895-
@skip_if_tsan_and_gil_disabled
18961895
def test_threaded_weak_valued_pop(self):
18971896
d = weakref.WeakValueDictionary()
18981897
with collect_in_thread():
1899-
for i in range(100000):
1898+
for i in range(self.NUM_THREADED_ITERATIONS):
19001899
d[10] = RefCycle()
19011900
x = d.pop(10, 10)
19021901
self.assertIsNot(x, None) # we never put None in there!
19031902

19041903
@threading_helper.requires_working_threading()
1905-
@skip_if_tsan_and_gil_disabled
19061904
def test_threaded_weak_valued_consistency(self):
19071905
# Issue #28427: old keys should not remove new values from
19081906
# WeakValueDictionary when collecting from another thread.
19091907
d = weakref.WeakValueDictionary()
19101908
with collect_in_thread():
1911-
for i in range(200000):
1909+
for i in range(2 * self.NUM_THREADED_ITERATIONS):
19121910
o = RefCycle()
19131911
d[10] = o
19141912
# o is still alive, so the dict can't be empty

0 commit comments

Comments
 (0)