Skip to content

bpo-45835: Fix race condition in test_queue#29601

Merged
pitrou merged 1 commit into
python:mainfrom
colesbury:issue45835
Nov 18, 2021
Merged

bpo-45835: Fix race condition in test_queue#29601
pitrou merged 1 commit into
python:mainfrom
colesbury:issue45835

Conversation

@colesbury

@colesbury colesbury commented Nov 17, 2021

Copy link
Copy Markdown
Contributor

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.
@pitrou

pitrou commented Nov 17, 2021

Copy link
Copy Markdown
Member

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
Copy Markdown

🤖 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

pitrou commented Nov 17, 2021

Copy link
Copy Markdown
Member

Wahoo.

@pitrou

pitrou commented Nov 18, 2021

Copy link
Copy Markdown
Member

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

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

Copy link
Copy Markdown
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
Copy Markdown

@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 <colesbury@gmail.com>
@bedevere-bot

Copy link
Copy Markdown

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 <colesbury@gmail.com>
@bedevere-bot

Copy link
Copy Markdown

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 <colesbury@gmail.com>
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 <colesbury@gmail.com>
@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