You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Chris Piro (JIRA)" <ji...@apache.org> on 2012/10/09 03:42:03 UTC

[jira] [Commented] (THRIFT-1704) Tornado support (Python)

    [ https://issues.apache.org/jira/browse/THRIFT-1704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13472052#comment-13472052 ] 

Chris Piro commented on THRIFT-1704:
------------------------------------

Does anyone else have feedback? The changes are self-contained in {{--gen py:tornado}}, so it shouldn't affect existing users. I'll go ahead and commit if there aren't any objections.
                
> Tornado support (Python)
> ------------------------
>
>                 Key: THRIFT-1704
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1704
>             Project: Thrift
>          Issue Type: New Feature
>          Components: Python - Compiler, Python - Library
>    Affects Versions: 0.9
>         Environment: Tornado 2.4.0 (https://github.com/facebook/tornado/tree/v2.4.0)
>            Reporter: Chris Piro
>         Attachments: thrift-1704-tornado-2.patch, thrift-1704-tornado.patch
>
>
> Add support for Tornado, the non-blocking server framework released by Facebook. The attached patch adds a {{--gen py:tornado}} option to the compiler, support bits to Python library, a tutorial server and client, and a modest unit test.
> The attached patch (against {{trunk}}) has been running in the critical path of a production web site for several months with modest load. It seems to work fine, though no serious attempt has been made to optimize for performance.
> some snippets from the tutorial server and client code, respectively:
> {code}
> class CalculatorHandler(object):
>     def add(self, n1, n2, callback):
>         callback(n1 + n2)
> def main():
>     handler = CalculatorHandler()
>     processor = Calculator.Processor(handler)
>     pfactory = TBinaryProtocol.TBinaryProtocolFactory()
>     server = TTornado.TTornadoServer(processor, pfactory)
>     server.bind(9090)
>     server.start(1)
>     ioloop.IOLoop.instance().start()
> {code}
> {code}
> transport = TTornado.TTornadoStreamTransport('localhost', 9090)
> pfactory = TBinaryProtocol.TBinaryProtocolFactory()
> client = Calculator.Client(transport, pfactory)
> yield gen.Task(transport.open)
> yield gen.Task(client.ping)
> sum_ = yield gen.Task(client.add, 1, 1)
> print "1 + 1 = {}".format(sum_)
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira