From 46118573ec9fb6a4ffcf053e6d005c57fd476014 Mon Sep 17 00:00:00 2001 From: Josh Rosenberg <26495692+MojoVampire@users.noreply.github.com> Date: Wed, 22 May 2024 10:30:36 -0400 Subject: [PATCH] Reduce readers in test_racing_join_replace to 10, use Event to synchronize, and perform multiple joins per loop to increase chance of repro without synchronization --- Lib/test/test_free_threading/test_str.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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 = []