import sys from thrift.protocol import TBinaryProtocol from thrift.transport import TSocket, TTransport sys.path.append('/root/PixivSearch') from PixivSearch.thrift.TestQry.TestQry import Client if __name__ == '__main__': # Make socket socket = TSocket.TSocket('mikuhime.xyz', 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(1))