Added assertion in greenpool to prevent infinite waits. Thanks to rtyler for the horrifying idea.
This commit is contained in:
@@ -110,6 +110,9 @@ class GreenPool(object):
|
||||
|
||||
def waitall(self):
|
||||
"""Waits until all greenthreads in the pool are finished working."""
|
||||
assert greenthread.getcurrent() not in self.coroutines_running, \
|
||||
"Calling waitall() from within one of the "\
|
||||
"GreenPool's greenthreads will never terminate."
|
||||
if self.running():
|
||||
self.no_coros_running.wait()
|
||||
|
||||
|
@@ -302,6 +302,11 @@ class GreenPool(tests.LimitedTestCase):
|
||||
p = greenpool.GreenPool()
|
||||
p.waitall()
|
||||
|
||||
def test_recursive_waitall(self):
|
||||
p = greenpool.GreenPool()
|
||||
gt = p.spawn(p.waitall)
|
||||
self.assertRaises(AssertionError, gt.wait)
|
||||
|
||||
|
||||
class GreenPile(tests.LimitedTestCase):
|
||||
def test_pile(self):
|
||||
|
Reference in New Issue
Block a user