Skip to content

gh-116631: Fix race condition in test_shutdown_immediate_put_join #116670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions Lib/test/test_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,6 @@ def _shutdown_put_join(self, immediate):
results = []
go = threading.Event()
q.put("Y")
nb = q.qsize()
# queue not fulled

thrds = (
Expand All @@ -578,13 +577,19 @@ def _shutdown_put_join(self, immediate):
for func, params in thrds:
threads.append(threading.Thread(target=func, args=params))
threads[-1].start()
self.assertEqual(q.unfinished_tasks, nb)
for i in range(nb):
t = threading.Thread(target=q.task_done)
t.start()
threads.append(t)
self.assertEqual(q.unfinished_tasks, 1)

q.shutdown(immediate)
go.set()

if immediate:
with self.assertRaises(self.queue.ShutDown):
q.get_nowait()
else:
result = q.get()
self.assertEqual(result, "Y")
q.task_done()

This comment was marked as resolved.

for t in threads:
t.join()

Expand Down