Skip to content

Instantly share code, notes, and snippets.

@zacharyvoase
Created March 12, 2009 01:40
Show Gist options
  • Save zacharyvoase/77859 to your computer and use it in GitHub Desktop.
Save zacharyvoase/77859 to your computer and use it in GitHub Desktop.
# -*- 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