本文整理汇总了Python中thrift.Thrift.TApplicationException.args方法的典型用法代码示例。如果您正苦于以下问题:Python TApplicationException.args方法的具体用法?Python TApplicationException.args怎么用?Python TApplicationException.args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thrift.Thrift.TApplicationException
的用法示例。
在下文中一共展示了TApplicationException.args方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: call
# 需要导入模块: from thrift.Thrift import TApplicationException [as 别名]
# 或者: from thrift.Thrift.TApplicationException import args [as 别名]
def call(self, procedure, args):
if isinstance(procedure, str):
try:
procedure = processor._procedures[procedure]
except KeyError:
raise TApplicationException(TApplicationException.UNKNOWN_METHOD,
"Unknown method '{0}'".format(name))
otrans = TMemoryBuffer()
oproto = TBinaryProtocol(otrans)
# perf.begin('send')
oproto.writeMessageBegin(procedure.name, TMessageType.CALL, self._processor.seqid)
self._processor.seqid = self._processor.seqid + 1
self._processor.send_struct(Namespace(args), procedure.parameters_struct, oproto)
oproto.writeMessageEnd()
# perf.end('send')
self._http.request('POST', self._url, otrans.getvalue(), {})
resp = self._http.getresponse()
data = resp.read()
iproto = TBinaryProtocol(TMemoryBuffer(data))
# perf.begin('wait')
(fname, mtype, rseqid) = iproto.readMessageBegin()
# perf.end('wait')
# perf.begin('recv')
if mtype == TMessageType.EXCEPTION:
x = TApplicationException()
x.read(iproto)
iproto.readMessageEnd()
x.args = (x.message,)
raise x
result = self._processor.recv_struct(procedure.results_struct, iproto)
iproto.readMessageEnd()
# perf.end('recv')
# perf.end('call')
if result.result is not None:
return result.result
for field in procedure.results_struct.fields:
if getattr(result, field.name) is not None:
raise getattr(result, field.name)
return None
示例2: call
# 需要导入模块: from thrift.Thrift import TApplicationException [as 别名]
# 或者: from thrift.Thrift.TApplicationException import args [as 别名]
def call(self, procedure, args, iproto, oproto):
# perf.begin('call')
if isinstance(procedure, str):
try:
procedure = self._procedures[procedure]
except KeyError:
raise TApplicationException(TApplicationException.UNKNOWN_METHOD,
"Unknown method '{0}'".format(name))
# perf.begin('send')
oproto.writeMessageBegin(procedure.name, TMessageType.CALL, self.seqid)
self.seqid = self.seqid + 1
self.send_struct(Namespace(args), procedure.parameters_struct, oproto)
oproto.writeMessageEnd()
oproto.trans.flush()
# perf.end('send')
# perf.begin('wait')
(fname, mtype, rseqid) = iproto.readMessageBegin()
# perf.end('wait')
# perf.begin('recv')
if mtype == TMessageType.EXCEPTION:
x = TApplicationException()
x.read(iproto)
iproto.readMessageEnd()
x.args = (x.message,)
raise x
result = self.recv_struct(procedure.results_struct, iproto)
iproto.readMessageEnd()
# perf.end('recv')
# perf.end('call')
if result.result is not None:
return result.result
for field in procedure.results_struct.fields:
if getattr(result, field.name) is not None:
raise getattr(result, field.name)
return None