queue: Make join not wait if there are no unfinished tasks

This fixes GitHub issue #54
This commit is contained in:
Jakub Stasiak
2014-01-28 21:00:41 +00:00
committed by Sergey Shepelev
parent 7932fc4efb
commit 76a8cdcdae
2 changed files with 6 additions and 1 deletions

View File

@@ -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):

View File

@@ -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: