@@ -1255,6 +1255,12 @@ class MappingTestCase(TestBase):
12551255
12561256 COUNT = 10
12571257
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+
12581264 def check_len_cycles (self , dict_type , cons ):
12591265 N = 20
12601266 items = [RefCycle () for i in range (N )]
@@ -1880,7 +1886,7 @@ def test_make_weak_keyed_dict_repr(self):
18801886 def test_threaded_weak_valued_setdefault (self ):
18811887 d = weakref .WeakValueDictionary ()
18821888 with collect_in_thread ():
1883- for i in range (100000 ):
1889+ for i in range (self . NUM_THREADED_ITERATIONS ):
18841890 x = d .setdefault (10 , RefCycle ())
18851891 self .assertIsNot (x , None ) # we never put None in there!
18861892 del x
@@ -1889,7 +1895,7 @@ def test_threaded_weak_valued_setdefault(self):
18891895 def test_threaded_weak_valued_pop (self ):
18901896 d = weakref .WeakValueDictionary ()
18911897 with collect_in_thread ():
1892- for i in range (100000 ):
1898+ for i in range (self . NUM_THREADED_ITERATIONS ):
18931899 d [10 ] = RefCycle ()
18941900 x = d .pop (10 , 10 )
18951901 self .assertIsNot (x , None ) # we never put None in there!
@@ -1900,7 +1906,7 @@ def test_threaded_weak_valued_consistency(self):
19001906 # WeakValueDictionary when collecting from another thread.
19011907 d = weakref .WeakValueDictionary ()
19021908 with collect_in_thread ():
1903- for i in range (200000 ):
1909+ for i in range (2 * self . NUM_THREADED_ITERATIONS ):
19041910 o = RefCycle ()
19051911 d [10 ] = o
19061912 # o is still alive, so the dict can't be empty
0 commit comments