Skip to content

Instantly share code, notes, and snippets.

@pawl
Last active March 21, 2017 02:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pawl/5e1e71e6b9f410d4491fe68c24b9977a to your computer and use it in GitHub Desktop.
Save pawl/5e1e71e6b9f410d4491fe68c24b9977a to your computer and use it in GitHub Desktop.
demonstrates issue with thrift service swallowing TTransportException
service PingPong {
string ping(),
}
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())
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()
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