File tree Expand file tree Collapse file tree
Lib/test/test_free_threading Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55
66class SysModuleTest (unittest .TestCase ):
77 def test_int_max_str_digits_thread (self ):
8- # gh-151218: Check that it's safe to call set_int_max_str_digits()
9- # in parallel. Previously, this test triggered warnings in TSan
10- # on a free threaded build.
8+ # gh-151218: Check that it's safe to call get_int_max_str_digits() and
9+ # set_int_max_str_digits() in parallel. Previously, this test triggered
10+ # warnings in TSan on a free threaded build.
1111
1212 old_limit = sys .get_int_max_str_digits ()
1313 self .addCleanup (sys .set_int_max_str_digits , old_limit )
1414
15- def worker ():
16- for i in range (20_000 ):
17- sys .set_int_max_str_digits (4300 + (i & 7 ))
15+ def worker (worker_id ):
16+ if not worker_id :
17+ for i in range (20_000 ):
18+ sys .get_int_max_str_digits ()
19+ else :
20+ for i in range (20_000 ):
21+ sys .set_int_max_str_digits (4300 + (i & 7 ))
1822
19- threading_helper .run_concurrently (worker , nthreads = 4 )
23+ workers = [lambda : worker (i ) for i in range (5 )]
24+ threading_helper .run_concurrently (workers )
2025
2126
2227if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments