summaryrefslogtreecommitdiff
path: root/eventlet/greenpool.py
diff options
context:
space:
mode:
authorSergey Shepelev <temotor@gmail.com>2014-04-24 17:51:27 +0400
committerSergey Shepelev <temotor@gmail.com>2014-04-24 18:11:37 +0400
commitcbd404d56e231ea5419f07795a12d7082dd70ec4 (patch)
tree7ad24a0f80e064b94108bb38b8c4a8a3eebafb44 /eventlet/greenpool.py
parentc467ded4a6e777518cd7a3888149510e3b31d334 (diff)
downloadeventlet-cbd404d56e231ea5419f07795a12d7082dd70ec4.tar.gz
python3 compatibility
- __next__ for iterator interface - six.next() to get next item - list(dict.keys()) - popen2.popen4 -> subprocess - s2b -> b"..." literals - deprecated assertEquals -> assertEqual - hub_test test_fork using run_python - 1L -> 1 long literal - many PEP-8 fixes
Diffstat (limited to 'eventlet/greenpool.py')
-rw-r--r--eventlet/greenpool.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/eventlet/greenpool.py b/eventlet/greenpool.py
index fb157b8..fd78ba0 100644
--- a/eventlet/greenpool.py
+++ b/eventlet/greenpool.py
@@ -11,6 +11,7 @@ __all__ = ['GreenPool', 'GreenPile']
DEBUG = True
+
class GreenPool(object):
"""The GreenPool class is a pool of green threads.
"""
@@ -102,7 +103,8 @@ class GreenPool(object):
self._spawn_n_impl(function, args, kwargs, None)
else:
self.sem.acquire()
- g = greenthread.spawn_n(self._spawn_n_impl,
+ g = greenthread.spawn_n(
+ self._spawn_n_impl,
function, args, kwargs, True)
if not self.coroutines_running:
self.no_coros_running = event.Event()
@@ -111,8 +113,8 @@ 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."
+ "Calling waitall() from within one of the " \
+ "GreenPool's greenthreads will never terminate."
if self.running():
self.no_coros_running.wait()
@@ -197,7 +199,7 @@ class GreenPile(object):
def spawn(self, func, *args, **kw):
"""Runs *func* in its own green thread, with the result available by
iterating over the GreenPile object."""
- self.used = True
+ self.used = True
self.counter += 1
try:
gt = self.pool.spawn(func, *args, **kw)
@@ -218,6 +220,8 @@ class GreenPile(object):
return self.waiters.get().wait()
finally:
self.counter -= 1
+ __next__ = next
+
# this is identical to GreenPile but it blocks on spawn if the results
# aren't consumed, and it doesn't generate its own StopIteration exception,
@@ -236,3 +240,4 @@ class GreenMap(GreenPile):
return val
finally:
self.counter -= 1
+ __next__ = next