uber/doubles

Native support for Tornado futures

Closed this issue · 0 comments

Currently, if a method being doubled is an asynchronous operation, we use tornado.gen.maybe_future to wrap values into futures, and for exceptions for asynchronous operations, we use this:

def failed_future(exc):
    future = tornado.gen.Future()
    future.set_exception(exc)
    return future

It would be great if doubles supported futures natively. The API could possibly look like,

allow(foo).bar.and_raise.async(Exception('foo'))
allow(foo).bar.and_return.async(result)

Doubles won't have to depend on Tornado for this and can just use the futures from concurrent.futures since Tornado supports those too.