This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: queue.Queue().join() add a timeout option
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Add timeout parameter to Queue.join()
View: 9634
Assigned To: Nosy List: AsynchronousGillz, rhettinger
Priority: normal Keywords: patch

Created on 2020-11-20 20:55 by AsynchronousGillz, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 23432 closed AsynchronousGillz, 2020-11-20 22:03
Messages (2)
msg381506 - (view) Author: Gerhard van Andel (AsynchronousGillz) * Date: 2020-11-20 20:55
class Queue:

    def join():
        ...

# Can we add a timeout option to the join method on queue.Queue 

    def join(timeout=None):
        '''Blocks until all items in the Queue have been gotten and processed.

        The count of unfinished tasks goes up whenever an item is added to the
        queue. The count goes down whenever a consumer thread calls task_done()
        to indicate the item was retrieved and all work on it is complete. If
        'timeout' is a non-negative number, it blocks at most 'timeout' seconds
        and raises the Full exception if no free slot was available within that
        time.

        When the count of unfinished tasks drops to zero, join() unblocks.
        '''
        if timeout and timeout < 0:
            raise ValueError("'timeout' must be a non-negative number")
        with self.all_tasks_done:
            while self.unfinished_tasks:
                self.all_tasks_done.wait(timeout)
msg381512 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-11-20 23:53
Marking this as a duplicate because it has come up before.
History
Date User Action Args
2022-04-11 14:59:38adminsetgithub: 86586
2020-11-20 23:53:43rhettingersetstatus: open -> closed

superseder: Add timeout parameter to Queue.join()

nosy: + rhettinger
messages: + msg381512
resolution: duplicate
stage: patch review -> resolved
2020-11-20 22:03:10AsynchronousGillzsetkeywords: + patch
stage: patch review
pull_requests: + pull_request22323
2020-11-20 20:55:27AsynchronousGillzcreate