def client_context(service, host, port, proto_factory=TBinaryProtocolFactory()): try: transport = TBufferedTransport(TSocket(host, port)) protocol = proto_factory.get_protocol(transport) transport.open() yield TClient(service, protocol) finally: transport.close()
def make_client(service, host, port, proto_factory=TBinaryProtocolFactory()): transport = TBufferedTransport(TSocket(host, port)) protocol = proto_factory.get_protocol(transport) transport.open() return TClient(service, protocol)