Skip to content

Commit e5280f1

Browse files
committed
Add get_int_max_str_digits() to the test
1 parent f114294 commit e5280f1

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

Lib/test/test_free_threading/test_sys.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,23 @@
55

66
class 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

2227
if __name__ == "__main__":

0 commit comments

Comments
 (0)