Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If the function returns a future, handle things asynchronously #12

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

spanezz
Copy link
Contributor

@spanezz spanezz commented Feb 6, 2015

Currently I can use @async to make a xmlrpc server method asynchronous, but with tornado.gen and friends, I tried to make it so that I could use a @gen.coroutine instead. The first step was to make it so that if an xmlrpc method returns a Future, it is run asynchronously and its result is returned transparently.

Unfortunately, @gen.coroutines still cannot be used transparently, because the wrapper that they create confuses tornadorpc's getcallargs. Still, I find this change quite handy.

With regards to using gen.coroutines, at least now I can do this:

class RpcHandler(XMLRPCHandler):
    def foo(self):
        @gen.coroutine
        def run():
            result1 = yield something(1, 2, 3)
            result2 = yield somethingelse(3, 4, 5)
            raise gen.Return(result1 + result2)
        return run()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants