Fix for waitall with nothing running
This commit is contained in:
@@ -119,7 +119,8 @@ class GreenPool(object):
|
|||||||
|
|
||||||
def waitall(self):
|
def waitall(self):
|
||||||
"""Waits until all greenthreads in the pool are finished working."""
|
"""Waits until all greenthreads in the pool are finished working."""
|
||||||
self.no_coros_running.wait()
|
if self.running():
|
||||||
|
self.no_coros_running.wait()
|
||||||
|
|
||||||
def _spawn_done(self, coro):
|
def _spawn_done(self, coro):
|
||||||
self.sem.release()
|
self.sem.release()
|
||||||
@@ -228,4 +229,4 @@ class GreenMap(GreenPile):
|
|||||||
try:
|
try:
|
||||||
return self.waiters.get().wait()
|
return self.waiters.get().wait()
|
||||||
finally:
|
finally:
|
||||||
self.counter -= 1
|
self.counter -= 1
|
||||||
|
@@ -297,6 +297,11 @@ class GreenPool(tests.LimitedTestCase):
|
|||||||
p = greenpool.GreenPool(4)
|
p = greenpool.GreenPool(4)
|
||||||
result_list = list(p.starmap(passthru, [(x,) for x in xrange(10)]))
|
result_list = list(p.starmap(passthru, [(x,) for x in xrange(10)]))
|
||||||
self.assertEquals(result_list, range(10))
|
self.assertEquals(result_list, range(10))
|
||||||
|
|
||||||
|
def test_waitall_on_nothing(self):
|
||||||
|
p = greenpool.GreenPool()
|
||||||
|
p.waitall()
|
||||||
|
|
||||||
|
|
||||||
class GreenPile(tests.LimitedTestCase):
|
class GreenPile(tests.LimitedTestCase):
|
||||||
def test_pile(self):
|
def test_pile(self):
|
||||||
@@ -454,4 +459,4 @@ class Stress(tests.LimitedTestCase):
|
|||||||
subtest(50, 75, 100)
|
subtest(50, 75, 100)
|
||||||
for isize in (10, 20, 30, 40, 50):
|
for isize in (10, 20, 30, 40, 50):
|
||||||
for psize in (5, 25, 35, 50):
|
for psize in (5, 25, 35, 50):
|
||||||
subtest(isize, psize, psize)
|
subtest(isize, psize, psize)
|
||||||
|
Reference in New Issue
Block a user