Created
March 12, 2009 01:40
-
-
Save zacharyvoase/77859 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import eventlet | |
import eventlet.api | |
import eventlet.coros | |
def call_cc(function): | |
ev = eventlet.coros.event() | |
function(ev.send) | |
return ev.wait() | |
def coro_poolize(**kwargs): | |
"""Takes a function and gives it a personal CoroutinePool.""" | |
def decorator(function): | |
pool = eventlet.coros.CoroutinePool(**kwargs) | |
def wrapper(*args, **kwargs): | |
return pool.execute(function, *args, **kwargs) | |
wrapper.__name__ = function.__name__ | |
wrapper.__doc__ = function.__doc__ | |
wrapper.original_function = function | |
wrapper.pool = pool | |
return wrapper | |
return decorator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment