Last active
March 21, 2017 02:26
-
-
Save pawl/5e1e71e6b9f410d4491fe68c24b9977a to your computer and use it in GitHub Desktop.
demonstrates issue with thrift service swallowing TTransportException
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service PingPong { | |
string ping(), | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import thriftpy | |
from thriftpy.rpc import make_client | |
logging.basicConfig(level=logging.DEBUG) | |
pingpong_thrift = thriftpy.load("pingpong.thrift", | |
module_name="pingpong_thrift") | |
client = make_client(pingpong_thrift.PingPong, '127.0.0.1', 6000) | |
print(client.ping()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import thriftpy | |
from thriftpy.rpc import make_server | |
logging.basicConfig(level=logging.DEBUG) | |
pingpong_thrift = thriftpy.load( | |
"pingpong.thrift", | |
module_name="pingpong_thrift", | |
) | |
class Dispatcher(object): | |
def ping(self): | |
return 123 # should be string! | |
server = make_server( | |
service=pingpong_thrift.PingPong, | |
handler=Dispatcher(), | |
host='127.0.0.1', | |
port=6001, | |
) | |
server.serve() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import thriftpy | |
from thriftpy.rpc import make_server | |
from thriftpy.rpc import make_client | |
logging.basicConfig(level=logging.DEBUG) | |
pingpong_thrift = thriftpy.load( | |
"pingpong.thrift", | |
module_name="pingpong_thrift", | |
) | |
class Dispatcher(object): | |
def ping(self): | |
client = make_client(pingpong_thrift.PingPong, '127.0.0.1', 6001) | |
return client.ping() | |
server = make_server( | |
service=pingpong_thrift.PingPong, | |
handler=Dispatcher(), | |
host='127.0.0.1', | |
port=6000, | |
) | |
server.serve() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment