当前位置: 首页>>代码示例>>Python>>正文


Python TApplicationException.args方法代码示例

本文整理汇总了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
开发者ID:zielmicha,项目名称:satori,代码行数:49,代码来源:client.py

示例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
开发者ID:zielmicha,项目名称:satori,代码行数:43,代码来源:processor.py


注:本文中的thrift.Thrift.TApplicationException.args方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。