Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.

Is the Tornado server asynchronous? #305

Closed
julioasotodv opened this issue Jul 8, 2017 · 2 comments
Closed

Is the Tornado server asynchronous? #305

julioasotodv opened this issue Jul 8, 2017 · 2 comments

Comments

@julioasotodv
Copy link

julioasotodv commented Jul 8, 2017

I am trying to run the example in the docs (in tornado.py):

pingpong = thriftpy.load("pingpong.thrift")
class Dispatcher(object):
    def ping(self):
        return "pong"

server = make_server(pingpong.PingPong, Dispatcher())
server.listen(6000)

This isn't asynchronous Tornado code (since there is no @coroutine decorator in the Dispatcherclass, and it actuallty returns as any simple function).

Can be thriftpy's Tornado server asynchronous in any way?

@microdog
Copy link
Contributor

The Tornado server implemented by thriftpy is asynchronous(using tornado.tcpserver.TCPServer). You can define methods with @gen.coroutine decorator or methods returning Future object.

class Dispatcher(object):
    @gen.coroutine
    def ping(self):
        yield gen.sleep(10)
        raise gen.Return("pong")

@julioasotodv
Copy link
Author

Hi,

Yes, you are definetly right. I tried it before, but the problem was that I was trying to send lots of calls in parallel, but from the same client (which isn't async), so I couldn't be able to get benefit from async server side code.

Thank you very much. Great library btw :)

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

No branches or pull requests

2 participants