mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 10:48:51 +00:00
c9676569ad
Summary: Yep, it's up and running. We now have full client/server support in all of C++ Java PHP and Python. Well, not quite... there's no PHP server, but honestly who wants one? Actually, if we do want one the framework will support writing is as a PHP file that can be served in apache like a web service (i.e. restserver.php would be thriftserver.php). But now that's rambling and nothing to do with this commit. Notes: cheever, let's chat about porting your multithreaded Pillar Python server over to Thrift git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664783 13f79535-47bb-0310-9956-ffa450edef68
61 lines
1.3 KiB
Python
Executable File
61 lines
1.3 KiB
Python
Executable File
#!/usr/bin/python
|
|
|
|
import sys
|
|
sys.path.append('./gen-py')
|
|
|
|
import ThriftTest
|
|
from ThriftTest_types import *
|
|
from thrift.transport import TTransport
|
|
from thrift.transport import TSocket
|
|
from thrift.protocol import TBinaryProtocol
|
|
|
|
import timing
|
|
|
|
transport = TTransport.TBufferedTransport(TSocket.TSocket('localhost', 9090))
|
|
protocol = TBinaryProtocol.TBinaryProtocol()
|
|
client = ThriftTest.Client(transport, protocol)
|
|
|
|
transport.open()
|
|
|
|
# Start debug timing
|
|
timing.start()
|
|
|
|
print "testVoid()"
|
|
print client.testVoid()
|
|
|
|
print "testString('Python')"
|
|
print client.testString('Python')
|
|
|
|
print "testByte(63)"
|
|
print client.testByte(63)
|
|
|
|
print "testI32(-1)"
|
|
print client.testI32(-1)
|
|
|
|
print "testI64(-34359738368)"
|
|
print client.testI64(-34359738368)
|
|
|
|
print "testStruct({Zero, 1, -3, -5})"
|
|
x = Xtruct()
|
|
x.string_thing = "Zero"
|
|
x.byte_thing = 1
|
|
x.i32_thing = -3
|
|
x.i64_thing = -5
|
|
x = client.testStruct(x)
|
|
print "{%s, %d, %d, %d}" % (x.string_thing, x.byte_thing, x.i32_thing, x.i64_thing)
|
|
|
|
print "testException('Safe')"
|
|
print client.testException('Safe')
|
|
|
|
try:
|
|
print "textException('Xception')"
|
|
print client.testException('Xception')
|
|
|
|
except Xception, x:
|
|
print "Xception (%d, %s)" % (x.errorCode, x.message)
|
|
|
|
timing.finish()
|
|
print "Total time: %d microsecs" % timing.micro()
|
|
|
|
transport.close()
|