Uh oh!
There was an error while loading. Please reload this page.
gh-96471: Add threading queue shutdown - #104750
Conversation
* Include docs
* Include raised exception in docstrings * Handle queue shutdown in task_done and join * Factor out queue-state checks and updates to methods * Logic fixes in qsize, get and shutdown * Don't set unfinished_tasks to 0 on immediate shutdown * Updated tests * Document feature added in 3.13
Uh oh!
There was an error while loading. Please reload this page.
gvanrossum
left a comment
There was a problem hiding this comment.
Great progress. I mostly have some markup nits. But the tests seem to hang. Or was I just impatient?
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
gvanrossum
commented
Feb 7, 2024
Yeah, the test is definitely hanging for me. Have you figured that out yet? |
gvanrossum
commented
Feb 7, 2024
I'd also recommend a merge. :-) |
…tdown-immediate-consume
@gvanrossum It's intermittently hanging in the test I think the solution is to simply ensure Perhaps it's simpler to set Edit: I just noticed that this pull request's description says that It's also intermittently hanging in the test Solution here (which fixes the assertion for Edit: and of course now it's failing only in Windows (CI only succeeds because it re-runs |
Also shut down before put-join in shutdown-put-join tests. Also remove indent
9d0a083 to
9072c6fCompare
gvanrossum
left a comment
There was a problem hiding this comment.
LG, assuming you believe the test is stable. I have one nit, let me know how you feel about that.
Oh, one more thing. If you feel like writing documentation, could you update Doc/whatsnew/3.13.rst? There's a section about modified modules. A few lines there will go a long way.
Uh oh!
There was an error while loading. Please reload this page.
EpicWink
commented
Feb 9, 2024
Test is not stable, as |
gvanrossum
left a comment
There was a problem hiding this comment.
Excellent! All that remains is merging it (which I will take care of), closing the alternative PR for queue.py, and then we can have another look at the asyncio and multiprocessing queues. (For the latter we still need to find a reviewer.)
gvanrossum
commented
Feb 10, 2024
@EpicWink Sorry, it looks like we have to revert this until the Windows free-threading hang has been resolved. (Although it's possible that you've uncovered a Windows-related bug in free-threading, which is a developing feature.) |
gvanrossum
commented
Feb 11, 2024
FWIW, having had only a quick look at the failing test, is it possible that it relies on timeouts too much? I see that there's a 0.1 msec delay that is used for sleeping, and |
Co-authored-by: Duprat <yduprat@gmail.com>
gvanrossum
commented
Feb 22, 2024
From #104228 (comment): it looks like |
YvesDup
commented
Feb 22, 2024
Maybe I'm waking up a little too late, but despite having worked on the development 1 year ago, I have the impression that functionalities are missing in this merged PR. In the initial version of the feature (#104225), the basic shutdown just forbade The immediate shutdown prohibited all possible previous operations and had to release all threads blocked in Currently, in the following methods ( I don't want to hurt anyone's feelings, but I think this PR needs to be reworked (including documentation). PS: initial comment was done at the bad PR. Sorry |
EpicWink
commented
Feb 23, 2024
@YvesDup see comment in the issue: #96471 (comment) Basically, the goal is to have waiters (callers of queue methods) not be blocked on a queue which has been shut-down. Making the shutdown immediate simply means gets won't take anything more from the queue (and instead except). There is a problem with this PR though, in that |
YvesDup
commented
Feb 23, 2024
@EpicWink , thank you for this explanation. I ve missed that :-( |
YvesDup
commented
Feb 23, 2024
FYI, I fixed the failling test in |
gvanrossum
commented
Feb 23, 2024
Where can we see this? |
|
gvanrossum
commented
Feb 25, 2024
Thanks, I'll wait for the pull request. |
Uh oh!
There was an error while loading. Please reload this page.
YvesDup
commented
Mar 12, 2024
PR is ready on this issue (#115940). Sorry if I didn't understand that you wait for a PR linked to this one. Please let me know if I have to change. |
gvanrossum
commented
Mar 12, 2024
YvesDup
commented
Mar 12, 2024
gvanrossum
commented
Mar 12, 2024
@EpicWink: We're waiting for you! ^^ |
I'll review the new PR fixing the test today. My PR is another attempt, but unfinished. Perhaps in the future it can be added as another test. Edit: reviewed! |
Thank for the review. |
…ython#117532) (This is a small tweak of the original pythongh-104750 which added shutdown.)
Alternate implementation of #104225, where all queue items are consumed immediately in
Queue.shutdownwhenimmediate=Trueis passed (see the comparison for what's changed).task_doneandjoinwill now not raise after callingshutdown(immediate=True), rather they'll behave as if on a finished queue (joinreturns,task_doneraises the standardValueError)is_shutdownboolean attributeThis PR includes and modified changes from #104225.
📚 Documentation preview 📚: https://cpython-previews--104750.org.readthedocs.build/