Skip to content

bpo-45835: Fix race condition in test_queue #29601

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 1 commit into from
Nov 18, 2021
Merged

Conversation

colesbury
Copy link
Contributor

@colesbury colesbury commented Nov 17, 2021

Some of the tests in test_queue had a race condition in which a
non-sentinel value could be enqueued after the final sentinel value
leading to not all the inputs being processed (and test failures).

This changes feed() to enqueue a sentinel once the inputs are exhausted,
which guarantees that the final queued object is a sentinel. This
requires the number of feeder threads to match the number of consumer
threads, but that's already the case in the relevant tests.

https://bugs.python.org/issue45835

Some of the tests in test_queue had a race condition in which a
non-sentinel value could be enqueued after the final sentinel value
leading to not all the inputs being processed (and test failures).

This changes feed() to enqueue a sentinel once the inputs are exhausted,
which guarantees that the final queued object is a sentinel. This
requires the number of feeder threads to match the number of consumer
threads, but that's already the case in the relevant tests.
@bedevere-bot bedevere-bot added tests Tests in the Lib/test dir awaiting review labels Nov 17, 2021
@colesbury colesbury requested review from pitrou and ambv November 17, 2021 22:29
@colesbury colesbury added needs backport to 3.9 only security fixes needs backport to 3.10 only security fixes labels Nov 17, 2021
@pitrou
Copy link
Member

pitrou commented Nov 17, 2021

Can we run the buildbots on this?

@ambv ambv added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Nov 17, 2021
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @ambv for commit e49ee22 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Nov 17, 2021
@pitrou
Copy link
Member

pitrou commented Nov 17, 2021

Wahoo.

@pitrou
Copy link
Member

pitrou commented Nov 18, 2021

Ok, I'll assume the buildbot failures are unrelated.

@pitrou pitrou merged commit df3e53d into python:main Nov 18, 2021
@miss-islington
Copy link
Contributor

Thanks @colesbury for the PR, and @pitrou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@bedevere-bot
Copy link

@pitrou: Please replace # with GH- in the commit message next time. Thanks!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 18, 2021
Some of the tests in test_queue had a race condition in which a
non-sentinel value could be enqueued after the final sentinel value
leading to not all the inputs being processed (and test failures).

This changes feed() to enqueue a sentinel once the inputs are exhausted,
which guarantees that the final queued object is a sentinel. This
requires the number of feeder threads to match the number of consumer
threads, but that's already the case in the relevant tests.
(cherry picked from commit df3e53d)

Co-authored-by: Sam Gross <[email protected]>
@bedevere-bot
Copy link

GH-29612 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Nov 18, 2021
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 18, 2021
Some of the tests in test_queue had a race condition in which a
non-sentinel value could be enqueued after the final sentinel value
leading to not all the inputs being processed (and test failures).

This changes feed() to enqueue a sentinel once the inputs are exhausted,
which guarantees that the final queued object is a sentinel. This
requires the number of feeder threads to match the number of consumer
threads, but that's already the case in the relevant tests.
(cherry picked from commit df3e53d)

Co-authored-by: Sam Gross <[email protected]>
@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Nov 18, 2021
@bedevere-bot
Copy link

GH-29613 is a backport of this pull request to the 3.9 branch.

ambv pushed a commit that referenced this pull request Nov 18, 2021
Some of the tests in test_queue had a race condition in which a
non-sentinel value could be enqueued after the final sentinel value
leading to not all the inputs being processed (and test failures).

This changes feed() to enqueue a sentinel once the inputs are exhausted,
which guarantees that the final queued object is a sentinel. This
requires the number of feeder threads to match the number of consumer
threads, but that's already the case in the relevant tests.
(cherry picked from commit df3e53d)

Co-authored-by: Sam Gross <[email protected]>
miss-islington added a commit that referenced this pull request Nov 18, 2021
Some of the tests in test_queue had a race condition in which a
non-sentinel value could be enqueued after the final sentinel value
leading to not all the inputs being processed (and test failures).

This changes feed() to enqueue a sentinel once the inputs are exhausted,
which guarantees that the final queued object is a sentinel. This
requires the number of feeder threads to match the number of consumer
threads, but that's already the case in the relevant tests.
(cherry picked from commit df3e53d)

Co-authored-by: Sam Gross <[email protected]>
@colesbury colesbury deleted the issue45835 branch November 18, 2021 19:15
remykarem pushed a commit to remykarem/cpython that referenced this pull request Dec 7, 2021
Some of the tests in test_queue had a race condition in which a
non-sentinel value could be enqueued after the final sentinel value
leading to not all the inputs being processed (and test failures).

This changes feed() to enqueue a sentinel once the inputs are exhausted,
which guarantees that the final queued object is a sentinel. This
requires the number of feeder threads to match the number of consumer
threads, but that's already the case in the relevant tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants