summaryrefslogtreecommitdiff
path: root/eventlet/greenpool.py
diff options
context:
space:
mode:
authorRyan Williams <rdw@lindenlab.com>2010-01-18 01:22:08 -0800
committerRyan Williams <rdw@lindenlab.com>2010-01-18 01:22:08 -0800
commitb9a0269b0a1280218200b6b906fb2ef70d1e062a (patch)
tree277991e038c412b9329a6d5007ab618af8d64fda /eventlet/greenpool.py
parentb5a1ef713840d9398bc2f50881f92f29388caf5c (diff)
downloadeventlet-b9a0269b0a1280218200b6b906fb2ef70d1e062a.tar.gz
Cleaned up link implementation in greenthread, added greenthread test module, fixed kill's implementation to resolve the race condition.
Diffstat (limited to 'eventlet/greenpool.py')
-rw-r--r--eventlet/greenpool.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/eventlet/greenpool.py b/eventlet/greenpool.py
index a8398bc..4122734 100644
--- a/eventlet/greenpool.py
+++ b/eventlet/greenpool.py
@@ -1,4 +1,5 @@
import itertools
+import traceback
from eventlet import coros
from eventlet import event
@@ -69,24 +70,23 @@ class GreenPool(object):
if not self.coroutines_running:
self.no_coros_running = event.Event()
self.coroutines_running.add(gt)
- gt.link(self._spawn_done, coro=gt)
+ gt.link(self._spawn_done)
return gt
def _spawn_n_impl(self, func, args, kwargs, coro=None):
try:
try:
func(*args, **kwargs)
- except (KeyboardInterrupt, SystemExit):
+ except (KeyboardInterrupt, SystemExit, GreenletExit):
raise
except:
- # TODO in debug mode print these
- pass
+ traceback.print_exc()
finally:
if coro is None:
return
else:
coro = greenthread.getcurrent()
- self._spawn_done(coro=coro)
+ self._spawn_done(coro)
def spawn_n(self, func, *args, **kwargs):
""" Create a coroutine to run the *function*. Returns None; the results
@@ -108,12 +108,12 @@ class GreenPool(object):
"""Waits until all coroutines in the pool are finished working."""
self.no_coros_running.wait()
- def _spawn_done(self, result=None, exc=None, coro=None):
+ def _spawn_done(self, coro):
self.sem.release()
if coro is not None:
self.coroutines_running.remove(coro)
# if done processing (no more work is waiting for processing),
- # send StopIteration so that the queue knows it's done
+ # we can finish off any waitall() calls that might be pending
if self.sem.balance == self.size:
self.no_coros_running.send(None)