예제 #1
0
def run():
    handler = HelloHandler()
    processor = Hello.Processor(handler)
    pfacotry = TBinaryProtocol.TBinaryProtocolFactory()
    server = THttpServer.THttpServer(processor, ('127.0.0.1', 9090), pfacotry)
    print "starting server"
    server.serve()
    print "done"
예제 #2
0
def run():
    handler = HelloHandler()
    processor = Hello.Processor(handler)
    transport = TSocket.TServerSocket('127.0.0.1', 9090)

    tfactory = TTransport.TBufferedTransportFactory()
    pfactory = TBinaryProtocol.TBinaryProtocolFactory()

    server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)
    print "starting server"
    server.serve()
    print "done"
예제 #3
0
def main():
    handler = HelloHandler()
    processor = Hello.Processor(handler)
    pfactory = TJSONProtocolFactory()

    application = tornado.web.Application([
        (r"/thrift", ThriftWSHandler,
         dict(processor=processor,
              inputProtocolFactory=pfactory,
              outputProtocolFactory=pfactory))
    ])

    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()
예제 #4
0
    transport = TTransport.TBufferedTransport(transport)
    protocol = TJSONProtocol.TJSONProtocol(transport)

    client = Hello.Client(protocol)
    transport.open()
    print "server response:", client.sayHello()
    transport.close()


if __name__ == '__main__':
    if len(sys.argv) > 1 and sys.argv[1] == 'test':
        do_test()
        sys.exit(0)

    handler = HelloHandler()
    processor = Hello.Processor(handler)
    #transport = TSocket.TServerSocket(host='127.0.0.1', port=9090)
    tfactory = TTransport.TBufferedTransportFactory()
    pfactory = TJSONProtocol.TJSONProtocolFactory()

    #server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)
    host = 'localhost'
    port = 9090

    server = MyTHttpServer(processor, (host, port), pfactory)

    # You could do one of these for a multithreaded server
    # server = TServer.TThreadedServer(
    #     processor, transport, tfactory, pfactory)
    # server = TServer.TThreadPoolServer(
    #     processor, transport, tfactory, pfactory)