import sys from thrift.protocol import TBinaryProtocol from thrift.transport import TSocket, TTransport sys.path.append("/home/hua/PycharmProjects/PixivSearch") from PixivSearch.thrift.TestQry.TestQry import Client if __name__ == '__main__': # Make socket socket = TSocket.TSocket('127.0.0.1', 2233) # Buffering is critical. Raw sockets are very slow transport = TTransport.TFramedTransport(socket) if not transport.isOpen(): transport.open() # Wrap in a protocol protocol = TBinaryProtocol.TBinaryProtocol(transport) # Create a client to use the protocol encoder client = Client(protocol) print(client.qryTest(0))