Exemple #1
0
 def run(self):
     handler = KnnServiceHandler()
     processor = KnnThriftService.Processor(handler)
     transport = TSocket.TServerSocket(port=misc_config['port'])
     tfactory = TTransport.TBufferedTransportFactory()
     pfactory = TBinaryProtocol.TBinaryProtocolFactory()
     server = TServer.TThreadedServer(processor, transport, tfactory,
                                      pfactory)
     print "Starting python server..."
     server.serve()
Exemple #2
0
    def make_clients(self, host, port):
        """

        Args:
            host:
            port:

        Returns: thrift client for the worker at the given host and port

        """
        try:
            trans = TSocket.TSocket(host, port)
            trans = TTransport.TBufferedTransport(trans)
            proto = TBinaryProtocol.TBinaryProtocolAccelerated(trans)
            client = KnnThriftService.Client(proto)
            return client, trans
        except Thrift.TException as e:
            raise e
Exemple #3
0
 def get_client(self, host, port):
     trans = TSocket.TSocket(host, port)
     trans = TTransport.TBufferedTransport(trans)
     proto = TBinaryProtocol.TBinaryProtocolAccelerated(trans)
     client = KnnThriftService.Client(proto)
     return client, trans