Skip to content

Commit 87d894d

Browse files
committed
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
1 parent 07b31fa commit 87d894d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Lib/test/test_free_threading/test_str.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,21 @@ def test_racing_join_replace(self):
4242
'''
4343
l = [*'abcdefg']
4444
MAX_ORDINAL = 1_000
45-
READERS = 20
45+
READERS = 10
46+
done_event = Event()
4647

4748
def writer_func():
4849
for i, c in zip(cycle(range(len(l))),
4950
map(chr, range(128, MAX_ORDINAL))):
5051
l[i] = c
51-
del l[:] # Empty list to tell readers to exit
52+
done_event.set()
5253

5354
def reader_func():
54-
while True:
55-
empty = not l
55+
while not done_event.is_set():
56+
''.join(l)
57+
''.join(l)
58+
''.join(l)
5659
''.join(l)
57-
if empty:
58-
break
5960

6061
writer = Thread(target=writer_func)
6162
readers = []

0 commit comments

Comments
 (0)