@@ -1255,6 +1255,12 @@ class MappingTestCase(TestBase):
1255
1255
1256
1256
COUNT = 10
1257
1257
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
+
1258
1264
def check_len_cycles (self , dict_type , cons ):
1259
1265
N = 20
1260
1266
items = [RefCycle () for i in range (N )]
@@ -1880,7 +1886,7 @@ def test_make_weak_keyed_dict_repr(self):
1880
1886
def test_threaded_weak_valued_setdefault (self ):
1881
1887
d = weakref .WeakValueDictionary ()
1882
1888
with collect_in_thread ():
1883
- for i in range (100000 ):
1889
+ for i in range (self . NUM_THREADED_ITERATIONS ):
1884
1890
x = d .setdefault (10 , RefCycle ())
1885
1891
self .assertIsNot (x , None ) # we never put None in there!
1886
1892
del x
@@ -1889,7 +1895,7 @@ def test_threaded_weak_valued_setdefault(self):
1889
1895
def test_threaded_weak_valued_pop (self ):
1890
1896
d = weakref .WeakValueDictionary ()
1891
1897
with collect_in_thread ():
1892
- for i in range (100000 ):
1898
+ for i in range (self . NUM_THREADED_ITERATIONS ):
1893
1899
d [10 ] = RefCycle ()
1894
1900
x = d .pop (10 , 10 )
1895
1901
self .assertIsNot (x , None ) # we never put None in there!
@@ -1900,7 +1906,7 @@ def test_threaded_weak_valued_consistency(self):
1900
1906
# WeakValueDictionary when collecting from another thread.
1901
1907
d = weakref .WeakValueDictionary ()
1902
1908
with collect_in_thread ():
1903
- for i in range (200000 ):
1909
+ for i in range (2 * self . NUM_THREADED_ITERATIONS ):
1904
1910
o = RefCycle ()
1905
1911
d [10 ] = o
1906
1912
# o is still alive, so the dict can't be empty
0 commit comments