diff --git a/Lib/test/test_free_threading/test_str.py b/Lib/test/test_free_threading/test_str.py index b1bd9b43defb6ca..f5e93b7de0aa9b8 100644 --- a/Lib/test/test_free_threading/test_str.py +++ b/Lib/test/test_free_threading/test_str.py @@ -42,20 +42,21 @@ def test_racing_join_replace(self): ''' l = [*'abcdefg'] MAX_ORDINAL = 1_000 - READERS = 20 + READERS = 10 + done_event = Event() def writer_func(): for i, c in zip(cycle(range(len(l))), map(chr, range(128, MAX_ORDINAL))): l[i] = c - del l[:] # Empty list to tell readers to exit + done_event.set() def reader_func(): - while True: - empty = not l + while not done_event.is_set(): + ''.join(l) + ''.join(l) + ''.join(l) ''.join(l) - if empty: - break writer = Thread(target=writer_func) readers = []