def main(): dd_proc = TProcessor(dd_thrift.DingService, DingDispatcher()) pp_proc = TProcessor(pp_thrift.PingService, PingDispatcher()) mux_proc = TMultiplexedProcessor() mux_proc.register_processor(DD_SERVICE_NAME, dd_proc) mux_proc.register_processor(PP_SERVICE_NAME, pp_proc) server = TThreadedServer(mux_proc, TServerSocket(), iprot_factory=TBinaryProtocolFactory(), itrans_factory=TBufferedTransportFactory()) server.serve()
def gen_server(port, tracker=tracker, processor=TTrackedProcessor): args = [processor, addressbook.AddressBookService, Dispatcher()] if tracker: args.insert(1, tracker) processor = TProcessorFactory(*args) server_socket = TServerSocket(host="localhost", port=port) server = TSampleServer(processor, server_socket, prot_factory=TBinaryProtocolFactory(), trans_factory=TBufferedTransportFactory()) ps = multiprocessing.Process(target=server.serve) ps.start() return ps, server
def make_server( service, handler, host="127.0.0.1", port=9090, client_timeout=None, cert_file=None ): """Factory method to create a BartenderThriftServer""" if cert_file: server_socket = TSSLServerSocket( host=host, port=port, client_timeout=client_timeout, certfile=cert_file ) else: server_socket = TServerSocket( host=host, port=port, client_timeout=client_timeout ) return BartenderThriftServer( WrappedTProcessor("baseEx", bg_utils.bg_thrift.BaseException, service, handler), server_socket, )