def return_future ( fn ) : @ wraps ( fn ) def decorated ( * args , * * kwargs ) : return gen . maybe_future ( fn ( * args , * * kwargs ) ) return decorated
python wrap a future in a method
Decorator that turns a synchronous function into one returning a future .
def return_future(fn):
    """Decorator that turns a synchronous function into one returning a future.

    This should only be applied to non-blocking functions. Will do set_result()
    with the return value, or set_exc_info() if an exception is raised.

    """
    @wraps(fn)
    def decorated(*args, **kwargs):
        return gen.maybe_future(fn(*args, **kwargs))

    return decorated