This repository has been archived on 2018-06-04. You can view files and clone it, but cannot push or open issues/pull-requests.
thrift-helloworld/client.py

28 lines
661 B
Python

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