def main(): handler = CalculatorHandler() processor = Calculator.Processor(handler) pfactory = TBinaryProtocol.TBinaryProtocolFactory() server = TTornado.TTornadoServer(processor, pfactory) print("Starting the server...") server.bind(9090) server.start(1) ioloop.IOLoop.instance().start() print("done.")
def setUp(self): super(ThriftTestCase, self).setUp() self.port = get_unused_port() # server self.handler = TestHandler(self) self.processor = ThriftTest.Processor(self.handler) self.pfactory = TBinaryProtocol.TBinaryProtocolFactory() self.server = TTornado.TTornadoServer(self.processor, self.pfactory, io_loop=self.io_loop) self.server.bind(self.port) self.server.start(1) # client transport = TTornado.TTornadoStreamTransport('localhost', self.port, io_loop=self.io_loop) pfactory = TBinaryProtocol.TBinaryProtocolFactory() self.io_loop.run_sync(transport.open) self.client = ThriftTest.Client(transport, pfactory)
def setUp(self): self.port = get_unused_port() self.io_loop = self.get_new_ioloop() # server self.handler = TestHandler(self) self.processor = ThriftTest.Processor(self.handler) self.pfactory = TBinaryProtocol.TBinaryProtocolFactory() self.server = TTornado.TTornadoServer(self.processor, self.pfactory) self.server.bind(self.port) self.server.start(1) # client transport = TTornado.TTornadoStreamTransport('localhost', self.port) pfactory = TBinaryProtocol.TBinaryProtocolFactory() self.client = ThriftTest.Client(transport, pfactory) transport.open(callback=self.stop) self.wait(timeout=1)
def __create_server(processor, ip, port): pfactory = TCompactProtocol.TCompactProtocolFactory() server = TTornado.TTornadoServer(processor, pfactory) server.bind(port) return server