from helloworld import HelloWorld from helloworld.ttypes import * from helloworld.constants import * from thrift import Thrift from thrift.transport import TSocket, TTransport from thrift.protocol import TBinaryProtocol try: transport = TSocket.TSocket('localhost', 9090) transport = TTransport.TBufferedTransport(transport) protocol = TBinaryProtocol.TBinaryProtocol(transport) client = HelloWorld.Client(protocol) transport.open() resp = client.ping() print resp msg = Message(name='Ray', lang='jp') resp = client.sayHello(msg) print resp transport.close() except Thrift.TException, tx: print tx.message