Message157458
The function below is the workaround I plan to use based on the undocumented-but-public Thread attributes that relate to the task queue (it's essentially just a combination of Queue.join() with the existing structure of the Queue.get() implementation):
def join_queue(q, timeout=None):
q.all_tasks_done.acquire()
try:
if timeout is None:
while q.unfinished_tasks:
self.all_tasks_done.wait()
elif timeout < 0:
raise ValueError("'timeout' must be a positive number")
else:
endtime = _time() + timeout
while q.unfinished_tasks:
remaining = endtime - _time()
if remaining <= 0.0:
raise Pending
self.all_tasks_done.wait(remaining)
finally:
q.all_tasks_done.release() |
|
Date |
User |
Action |
Args |
2012-04-04 03:56:08 | ncoghlan | set | recipients:
+ ncoghlan, rhettinger, pitrou, kdlucas |
2012-04-04 03:56:08 | ncoghlan | set | messageid: <1333511768.18.0.125428097694.issue9634@psf.upfronthosting.co.za> |
2012-04-04 03:56:07 | ncoghlan | link | issue9634 messages |
2012-04-04 03:56:07 | ncoghlan | create | |
|