Skip to content

Commit

Permalink
Reduce readers in test_racing_join_replace to 10, use Event to synchr…
Browse files Browse the repository at this point in the history
…onize, and perform multiple joins per loop to increase chance of repro without synchronization
  • Loading branch information
MojoVampire committed May 22, 2024
1 parent 6067904 commit 4611857
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Lib/test/test_free_threading/test_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down

0 comments on commit 4611857

Please sign in to comment.