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
bpo-1360: Add warning to Queue.get() docs about block=True #2223
Conversation
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. Thanks again to your contribution and we look forward to looking at it! |
|
Just signed the CLA today. It will presumably take in the next couple of business days. |
|
|
I failed to check for this, sorry. It does appear to work, as you say. Should I make changes to this PR to apply it (at least for now) to 2.x maintenance only? What is the procedure for doing this? From my perspective, as a consumer of the queue lib not a maintainer, it's totally fine for For Windows, rather than hypothesize about the future of this operation, I'd like to document the current behavior. I don't have a Windows box ready-to-hand for testing, but it sounds like you're saying |
|
Yes, for Python 3 specifically on Windows, this PR can document that |
|
I've updated the warning to note the exact versions and platforms on which this is a problem. I would have liked to make the 2.x warning different from the 3.x warning, but I'm not sure what the dev workflow for that would be. Plus it makes backporting future changes to the doc harder. |
Doc/library/queue.rst
Outdated
| an uninterruptible wait on an underlying lock. | ||
|
|
||
| This means that no exceptions can occur, and in particular a SIGINT will | ||
| not trigger a ``KeyboardInterrupt``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when you do a reference to an exception, you can use the :exc: role like that :exc:`KeyboardInterrupt`
|
For a moment, I was going to retarget to py2.7, but looking more closely again, it's a valid fix for py2 and py3 docs. I've added the |
Doc/library/queue.rst
Outdated
| @@ -128,6 +128,15 @@ provide the public methods described below. | |||
| Otherwise (*block* is false), return an item if one is immediately available, | |||
| else raise the :exc:`Empty` exception (*timeout* is ignored in that case). | |||
|
|
|||
| .. warning:: | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just add this as plain text. The warning directive is typically saved for cases that are several or common. Otherwise, it creates visual litter than makes the docs hard to read (the eye is first drawn to the warning boxes).
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase And if you don't make the requested changes, you will be put in the comfy chair! |
|
Removed the I have made the requested changes; please review again. |
|
Thanks for making the requested changes! @rhettinger: please review the changes made to this pull request. |
| @@ -151,6 +151,14 @@ provide the public methods described below. | |||
| else raise the :exc:`Empty` exception (*timeout* is ignored in that case). | |||
|
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Remove this blank line.
Doc/library/queue.rst
Outdated
| Prior to 3.0 on POSIX systems, and for all versions on Windows, if | ||
| *block* is true and *timeout* is ``None``, this operation goes into | ||
| an uninterruptible wait on an underlying lock. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Join these two sentences into a single paragraph. The second sentence depends on the first and is the crux of the point being made.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
Python 2.7 is nearing end-of-life, so we're now mostly only backporting changes that are relatively important. |
When Queue.get() is called with `block=True` and `timeout=None`, the thread will block and wait on the Queue's not_empty condition variable without a timeout. Under these conditions, per the discussion in https://bugs.python.org/issue1360 , if the main thread is waiting on the get(), it will not respond to SIGINT. This can be a source of confusion in scripts which want to use Queues to wait on async processes, as Ctrl+C is commonplace. As noted in issue1360, this is unlikely to change because it would slow down lock acquisition, so update the docs to include a warning instead. As of 3.0, the uninterruptible nature of Queue.get() has changed. However, the problem remains on all versions for Windows. There doesn't seem to be prescriptive guidance for how to handle these kinds of version-specific warnings in any of the contributing guides. Simply describing the version/platform constraints seems fine.
|
I've amended with the copy-edit changes, and in case I haven't said above or forget to say it later: thanks for all of the review and attention!
Fair/understood. I agree that this isn't a very important change. I have made the requested changes; please review again. |
|
Thanks for making the requested changes! @rhettinger: please review the changes made to this pull request. |
|
Thanks @sirosen for the PR, and @rhettinger for merging it |
|
GH-12538 is a backport of this pull request to the 3.7 branch. |
(cherry picked from commit 713a8ae) Co-authored-by: Stephen Rosen <sirosen@globus.org>


When Queue.get() is called with
block=Trueandtimeout=None,the thread will block and wait on the Queue's not_empty condition
variable without a timeout. Under these conditions, per the discussion
in https://bugs.python.org/issue1360 , if the main thread is waiting on
the get(), it will not respond to SIGINT.
This can be a source of confusion in scripts which want to use Queues to
wait on async processes, as Ctrl+C is commonplace.
As noted in issue1360, this is unlikely to change because it would slow down
lock acquisition, so update the docs to include a warning instead.
I don't think there are other particularly interesting scenarios which
deserve explicit mention in the docs.
Needs to be backported to 2.7, and all 3.x maintenance branches.
https://bugs.python.org/issue1360