Fix for waitall with nothing running

This commit is contained in:
Gregory Holt
2010-01-26 18:47:16 +00:00
parent af59d5cc4d
commit f45922a26d
2 changed files with 9 additions and 3 deletions

View File

@@ -119,6 +119,7 @@ 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."""
if self.running():
self.no_coros_running.wait() self.no_coros_running.wait()
def _spawn_done(self, coro): def _spawn_done(self, coro):

View File

@@ -298,6 +298,11 @@ class GreenPool(tests.LimitedTestCase):
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):
p = greenpool.GreenPile(4) p = greenpool.GreenPile(4)