Commit 1586dcdc authored by Denis Bilenko's avatar Denis Bilenko

pool: add pass_value auxiliary class (this fixes apply_async)

parent e1a136cd
......@@ -210,3 +210,31 @@ class Pool(GreenletSet):
def get_values(greenlets):
joinall(greenlets)
return [x.value for x in greenlets]
class pass_value(object):
__slots__ = ['callback']
def __init__(self, callback):
self.callback = callback
def __call__(self, source):
if source.successful():
self.callback(source.value)
def __hash__(self):
return hash(self.callback)
def __eq__(self, other):
return self.callback == getattr(other, 'callback', other)
def __str__(self):
return str(self.callback)
def __repr__(self):
return repr(self.callback)
def __getattr__(self, item):
assert item != 'callback'
return getattr(self.callback, item)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment