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

Jake Farrell commented on THRIFT-1704:
--------------------------------------

Chris, i'm about to make the 0.9rc and would like to hold off on this till the 
next release as this hasnt been tested by more people yet
                
> 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

Reply via email to