[issue42420] queue.Queue().join() add a timeout option

2020-11-20 Thread Gerhard van Andel


New submission from Gerhard van Andel :

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 
<https://bugs.python.org/issue42420>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42420] queue.Queue().join() add a timeout option

2020-11-20 Thread Gerhard van Andel


Change by Gerhard van Andel :


--
keywords: +patch
pull_requests: +22323
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/23432

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