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): |     def waitall(self): | ||||||
|         """Waits until all greenthreads in the pool are finished working.""" |         """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(): |         if self.running(): | ||||||
|             self.no_coros_running.wait() |             self.no_coros_running.wait() | ||||||
|  |  | ||||||
|   | |||||||
| @@ -301,6 +301,11 @@ class GreenPool(tests.LimitedTestCase): | |||||||
|     def test_waitall_on_nothing(self): |     def test_waitall_on_nothing(self): | ||||||
|         p = greenpool.GreenPool() |         p = greenpool.GreenPool() | ||||||
|         p.waitall() |         p.waitall() | ||||||
|  |          | ||||||
|  |     def test_recursive_waitall(self): | ||||||
|  |         p = greenpool.GreenPool() | ||||||
|  |         gt = p.spawn(p.waitall) | ||||||
|  |         self.assertRaises(AssertionError, gt.wait) | ||||||
|  |  | ||||||
|              |              | ||||||
| class GreenPile(tests.LimitedTestCase): | class GreenPile(tests.LimitedTestCase): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Ryan Williams
					Ryan Williams