New submission from Gerhard van Andel <vanange...@gmail.com>:

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)

----------
components: Library (Lib)
messages: 381506
nosy: vananger93
priority: normal
severity: normal
status: open
title: queue.Queue().join() add a timeout option
type: enhancement
versions: Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42420>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to