Open
Description
Add a shutdown
method to queue class (threading queue
, multiprocessing
, asyncio
) which causes all future puts to raise (a queue.QueueShutdown
) and all future gets once the queue is empty to also raise, unblocking all waiters. An optional argument immediate=True
will skip the requirement for the queue to be empty.
This will enable producers and consumers to use the queue to know when to stop. This is important because both producers and consumers can be blocked waiting on the queue.
Previous discussion:
Linked PRs
- gh-96471: Add queue shutdown #96474
- gh-96471: Add queue shutdown, next step. #102499
- gh-96471: Add threading queue shutdown #104225
- gh-96471: Add asyncio queue shutdown #104228
- gh-96471: Add multiprocessing queue shutdown #104230
- gh-96471: Add threading queue shutdown #104750
- Revert "gh-96471: Add shutdown() method to queue.Queue (#104750)" #115265
- gh-96471: Correct docs for queue shutdown raises #115838
- gh-96471: Add ShutDown to threading module '__all__' #116699
- gh-96471: Correct documentation for asyncio queue shutdown #117621