queue: Make join not wait if there are no unfinished tasks
This fixes GitHub issue #54
This commit is contained in:
committed by
Sergey Shepelev
parent
7932fc4efb
commit
76a8cdcdae
@@ -418,7 +418,8 @@ class Queue(LightQueue):
|
||||
that the item was retrieved and all work on it is complete. When the count of
|
||||
unfinished tasks drops to zero, :meth:`join` unblocks.
|
||||
'''
|
||||
self._cond.wait()
|
||||
if self.unfinished_tasks > 0:
|
||||
self._cond.wait()
|
||||
|
||||
|
||||
class PriorityQueue(Queue):
|
||||
|
||||
@@ -253,6 +253,10 @@ class TestQueue(LimitedTestCase):
|
||||
assert channel.unfinished_tasks == 0, channel.unfinished_tasks
|
||||
gt.wait()
|
||||
|
||||
def test_join_doesnt_block_when_queue_is_already_empty(self):
|
||||
queue = eventlet.Queue()
|
||||
queue.join()
|
||||
|
||||
|
||||
def store_result(result, func, *args):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user