本文整理汇总了Python中thrift.Thrift.TApplicationException.write方法的典型用法代码示例。如果您正苦于以下问题:Python TApplicationException.write方法的具体用法?Python TApplicationException.write怎么用?Python TApplicationException.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thrift.Thrift.TApplicationException
的用法示例。
在下文中一共展示了TApplicationException.write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write_results_after_future
# 需要导入模块: from thrift.Thrift import TApplicationException [as 别名]
# 或者: from thrift.Thrift.TApplicationException import write [as 别名]
def write_results_after_future(
result, event_handler, handler_ctx, seqid, oprot, fn_name,
known_exceptions, future,
):
"""Result/exception handler for asyncio futures."""
try:
try:
result.success = future.result()
reply_type = TMessageType.REPLY
except TException as e:
for exc_name, exc_type in known_exceptions.items():
setattr(result, exc_name, e)
reply_type = TMessageType.REPLY
event_handler.handlerException(handler_ctx, fn_name, e)
break
else:
raise
except Exception as e:
result = TApplicationException(message=str(e))
reply_type = TMessageType.EXCEPTION
event_handler.handlerError(handler_ctx, fn_name, e)
event_handler.preWrite(handler_ctx, fn_name, result)
oprot.writeMessageBegin(fn_name, reply_type, seqid)
result.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()
event_handler.postWrite(handler_ctx, fn_name, result)
示例2: process_retrieveRequestToken
# 需要导入模块: from thrift.Thrift import TApplicationException [as 别名]
# 或者: from thrift.Thrift.TApplicationException import write [as 别名]
def process_retrieveRequestToken(self, seqid, iprot, oprot):
args = retrieveRequestToken_args()
args.read(iprot)
iprot.readMessageEnd()
result = retrieveRequestToken_result()
try:
result.success = self._handler.retrieveRequestToken(args.carrier)
msg_type = TMessageType.REPLY
except TTransport.TTransportException:
raise
except TalkException as e:
msg_type = TMessageType.REPLY
result.e = e
except TApplicationException as ex:
logging.exception('TApplication exception in handler')
msg_type = TMessageType.EXCEPTION
result = ex
except Exception:
logging.exception('Unexpected exception in handler')
msg_type = TMessageType.EXCEPTION
result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
oprot.writeMessageBegin("retrieveRequestToken", msg_type, seqid)
result.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()
示例3: process_getLocalAssignmentForStorm
# 需要导入模块: from thrift.Thrift import TApplicationException [as 别名]
# 或者: from thrift.Thrift.TApplicationException import write [as 别名]
def process_getLocalAssignmentForStorm(self, seqid, iprot, oprot):
args = getLocalAssignmentForStorm_args()
args.read(iprot)
iprot.readMessageEnd()
result = getLocalAssignmentForStorm_result()
try:
result.success = self._handler.getLocalAssignmentForStorm(args.id)
msg_type = TMessageType.REPLY
except TTransport.TTransportException:
raise
except NotAliveException as e:
msg_type = TMessageType.REPLY
result.e = e
except AuthorizationException as aze:
msg_type = TMessageType.REPLY
result.aze = aze
except TApplicationException as ex:
logging.exception('TApplication exception in handler')
msg_type = TMessageType.EXCEPTION
result = ex
except Exception:
logging.exception('Unexpected exception in handler')
msg_type = TMessageType.EXCEPTION
result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
oprot.writeMessageBegin("getLocalAssignmentForStorm", msg_type, seqid)
result.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()
示例4: process_getCapabilities
# 需要导入模块: from thrift.Thrift import TApplicationException [as 别名]
# 或者: from thrift.Thrift.TApplicationException import write [as 别名]
def process_getCapabilities(self, seqid, iprot, oprot):
args = getCapabilities_args()
args.read(iprot)
iprot.readMessageEnd()
result = getCapabilities_result()
try:
result.success = self._handler.getCapabilities()
msg_type = TMessageType.REPLY
except TTransport.TTransportException:
raise
except concrete.services.ttypes.ServicesException as ex:
msg_type = TMessageType.REPLY
result.ex = ex
except TApplicationException as ex:
logging.exception('TApplication exception in handler')
msg_type = TMessageType.EXCEPTION
result = ex
except Exception:
logging.exception('Unexpected exception in handler')
msg_type = TMessageType.EXCEPTION
result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
oprot.writeMessageBegin("getCapabilities", msg_type, seqid)
result.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()
示例5: process_fetchMessageOperations
# 需要导入模块: from thrift.Thrift import TApplicationException [as 别名]
# 或者: from thrift.Thrift.TApplicationException import write [as 别名]
def process_fetchMessageOperations(self, seqid, iprot, oprot):
args = fetchMessageOperations_args()
args.read(iprot)
iprot.readMessageEnd()
result = fetchMessageOperations_result()
try:
result.success = self._handler.fetchMessageOperations(args.localRevision, args.lastOpTimestamp, args.count)
msg_type = TMessageType.REPLY
except TTransport.TTransportException:
raise
except TalkException as e:
msg_type = TMessageType.REPLY
result.e = e
except TApplicationException as ex:
logging.exception('TApplication exception in handler')
msg_type = TMessageType.EXCEPTION
result = ex
except Exception:
logging.exception('Unexpected exception in handler')
msg_type = TMessageType.EXCEPTION
result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
oprot.writeMessageBegin("fetchMessageOperations", msg_type, seqid)
result.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()
示例6: process_failRequestV2
# 需要导入模块: from thrift.Thrift import TApplicationException [as 别名]
# 或者: from thrift.Thrift.TApplicationException import write [as 别名]
def process_failRequestV2(self, seqid, iprot, oprot):
args = failRequestV2_args()
args.read(iprot)
iprot.readMessageEnd()
result = failRequestV2_result()
try:
self._handler.failRequestV2(args.id, args.e)
msg_type = TMessageType.REPLY
except TTransport.TTransportException:
raise
except AuthorizationException as aze:
msg_type = TMessageType.REPLY
result.aze = aze
except TApplicationException as ex:
logging.exception('TApplication exception in handler')
msg_type = TMessageType.EXCEPTION
result = ex
except Exception:
logging.exception('Unexpected exception in handler')
msg_type = TMessageType.EXCEPTION
result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
oprot.writeMessageBegin("failRequestV2", msg_type, seqid)
result.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()
示例7: process_checkUserAgeWithDocomo
# 需要导入模块: from thrift.Thrift import TApplicationException [as 别名]
# 或者: from thrift.Thrift.TApplicationException import write [as 别名]
def process_checkUserAgeWithDocomo(self, seqid, iprot, oprot):
args = checkUserAgeWithDocomo_args()
args.read(iprot)
iprot.readMessageEnd()
result = checkUserAgeWithDocomo_result()
try:
result.success = self._handler.checkUserAgeWithDocomo(args.openIdRedirectUrl, args.standardAge, args.verifier)
msg_type = TMessageType.REPLY
except TTransport.TTransportException:
raise
except TalkException as e:
msg_type = TMessageType.REPLY
result.e = e
except TApplicationException as ex:
logging.exception('TApplication exception in handler')
msg_type = TMessageType.EXCEPTION
result = ex
except Exception:
logging.exception('Unexpected exception in handler')
msg_type = TMessageType.EXCEPTION
result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
oprot.writeMessageBegin("checkUserAgeWithDocomo", msg_type, seqid)
result.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()
示例8: process_notifyLeaveRoom
# 需要导入模块: from thrift.Thrift import TApplicationException [as 别名]
# 或者: from thrift.Thrift.TApplicationException import write [as 别名]
def process_notifyLeaveRoom(self, seqid, iprot, oprot):
args = notifyLeaveRoom_args()
args.read(iprot)
iprot.readMessageEnd()
result = notifyLeaveRoom_result()
try:
self._handler.notifyLeaveRoom(args.roomMid)
msg_type = TMessageType.REPLY
except TTransport.TTransportException:
raise
except TalkException as e:
msg_type = TMessageType.REPLY
result.e = e
except TApplicationException as ex:
logging.exception('TApplication exception in handler')
msg_type = TMessageType.EXCEPTION
result = ex
except Exception:
logging.exception('Unexpected exception in handler')
msg_type = TMessageType.EXCEPTION
result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
oprot.writeMessageBegin("notifyLeaveRoom", msg_type, seqid)
result.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()
示例9: process_annotate
# 需要导入模块: from thrift.Thrift import TApplicationException [as 别名]
# 或者: from thrift.Thrift.TApplicationException import write [as 别名]
def process_annotate(self, seqid, iprot, oprot):
args = annotate_args()
args.read(iprot)
iprot.readMessageEnd()
result = annotate_result()
try:
result.success = self._handler.annotate(args.original)
msg_type = TMessageType.REPLY
except TTransport.TTransportException:
raise
except concrete.exceptions.ttypes.ConcreteThriftException as ex:
msg_type = TMessageType.REPLY
result.ex = ex
except TApplicationException as ex:
logging.exception('TApplication exception in handler')
msg_type = TMessageType.EXCEPTION
result = ex
except Exception:
logging.exception('Unexpected exception in handler')
msg_type = TMessageType.EXCEPTION
result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
oprot.writeMessageBegin("annotate", msg_type, seqid)
result.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()
示例10: process_ping
# 需要导入模块: from thrift.Thrift import TApplicationException [as 别名]
# 或者: from thrift.Thrift.TApplicationException import write [as 别名]
def process_ping(self, seqid, iprot, oprot):
args = ping_args()
args.read(iprot)
iprot.readMessageEnd()
result = ping_result()
try:
result.success = self._handler.ping()
msg_type = TMessageType.REPLY
except TTransport.TTransportException:
raise
except AboutToShutDownException as shutdown_exception:
msg_type = TMessageType.REPLY
result.shutdown_exception = shutdown_exception
except TApplicationException as ex:
logging.exception('TApplication exception in handler')
msg_type = TMessageType.EXCEPTION
result = ex
except Exception:
logging.exception('Unexpected exception in handler')
msg_type = TMessageType.EXCEPTION
result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
oprot.writeMessageBegin("ping", msg_type, seqid)
result.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()
示例11: process_sendChatCheckedByWatermark
# 需要导入模块: from thrift.Thrift import TApplicationException [as 别名]
# 或者: from thrift.Thrift.TApplicationException import write [as 别名]
def process_sendChatCheckedByWatermark(self, seqid, iprot, oprot):
args = sendChatCheckedByWatermark_args()
args.read(iprot)
iprot.readMessageEnd()
result = sendChatCheckedByWatermark_result()
try:
self._handler.sendChatCheckedByWatermark(args.seq, args.mid, args.watermark, args.sessionId)
msg_type = TMessageType.REPLY
except TTransport.TTransportException:
raise
except TalkException as e:
msg_type = TMessageType.REPLY
result.e = e
except TApplicationException as ex:
logging.exception('TApplication exception in handler')
msg_type = TMessageType.EXCEPTION
result = ex
except Exception:
logging.exception('Unexpected exception in handler')
msg_type = TMessageType.EXCEPTION
result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
oprot.writeMessageBegin("sendChatCheckedByWatermark", msg_type, seqid)
result.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()
示例12: process_getBotUseInfo
# 需要导入模块: from thrift.Thrift import TApplicationException [as 别名]
# 或者: from thrift.Thrift.TApplicationException import write [as 别名]
def process_getBotUseInfo(self, seqid, iprot, oprot):
args = getBotUseInfo_args()
args.read(iprot)
iprot.readMessageEnd()
result = getBotUseInfo_result()
try:
result.success = self._handler.getBotUseInfo(args.botMid)
msg_type = TMessageType.REPLY
except TTransport.TTransportException:
raise
except TalkException as e:
msg_type = TMessageType.REPLY
result.e = e
except TApplicationException as ex:
logging.exception('TApplication exception in handler')
msg_type = TMessageType.EXCEPTION
result = ex
except Exception:
logging.exception('Unexpected exception in handler')
msg_type = TMessageType.EXCEPTION
result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
oprot.writeMessageBegin("getBotUseInfo", msg_type, seqid)
result.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()
示例13: process_postSnsInvitationMessage
# 需要导入模块: from thrift.Thrift import TApplicationException [as 别名]
# 或者: from thrift.Thrift.TApplicationException import write [as 别名]
def process_postSnsInvitationMessage(self, seqid, iprot, oprot):
args = postSnsInvitationMessage_args()
args.read(iprot)
iprot.readMessageEnd()
result = postSnsInvitationMessage_result()
try:
self._handler.postSnsInvitationMessage(args.snsIdType, args.snsAccessToken, args.toSnsUserId)
msg_type = TMessageType.REPLY
except TTransport.TTransportException:
raise
except TalkException as e:
msg_type = TMessageType.REPLY
result.e = e
except TApplicationException as ex:
logging.exception('TApplication exception in handler')
msg_type = TMessageType.EXCEPTION
result = ex
except Exception:
logging.exception('Unexpected exception in handler')
msg_type = TMessageType.EXCEPTION
result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
oprot.writeMessageBegin("postSnsInvitationMessage", msg_type, seqid)
result.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()
示例14: _handle_request
# 需要导入模块: from thrift.Thrift import TApplicationException [as 别名]
# 或者: from thrift.Thrift.TApplicationException import write [as 别名]
def _handle_request(self, listener_name, sock, addr):
client = TFileObjectTransport(sock.makefile())
itrans = self.tfactory.getTransport(client)
otrans = self.tfactory.getTransport(client)
iprot = self.pfactory.getProtocol(itrans)
oprot = self.pfactory.getProtocol(otrans)
try:
while True:
(name, type, seqid) = iprot.readMessageBegin()
request_start = time.time()
try:
timeout_con = Timeout(self.cfg.timeout, Timeout)
timeout_con.start()
if name not in self.wsgi._processMap:
iprot.skip(TType.STRUCT)
iprot.readMessageEnd()
x = TApplicationException(
TApplicationException.UNKNOWN_METHOD, "Unknown function %s" % (name))
oprot.writeMessageBegin(
name, TMessageType.EXCEPTION, seqid)
x.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()
raise ThriftFuncNotFound
else:
self.wsgi._processMap[name](self.wsgi, seqid, iprot, oprot)
except ThriftFuncNotFound, ex:
self.log.error("Unknown function %s" % (name))
self.log.access(
addr, name, "FUNC_NOT_FOUND", time.time() - request_start)
except Timeout, ex:
self.log.error("A greenlet process timeout.")
self.log.access(
addr, name, "TIMEOUT", time.time() - request_start)
示例15: process_create
# 需要导入模块: from thrift.Thrift import TApplicationException [as 别名]
# 或者: from thrift.Thrift.TApplicationException import write [as 别名]
def process_create(self, seqid, iprot, oprot):
args = create_args()
args.read(iprot)
iprot.readMessageEnd()
result = create_result()
try:
result.success = self._handler.create(args.request)
msg_type = TMessageType.REPLY
except (TTransport.TTransportException, KeyboardInterrupt, SystemExit):
raise
except ServiceUnavailable as service_error:
msg_type = TMessageType.REPLY
result.service_error = service_error
except ImageNotSupported as error:
msg_type = TMessageType.REPLY
result.error = error
except UploadImageError as image_error:
msg_type = TMessageType.REPLY
result.image_error = image_error
except Exception as ex:
msg_type = TMessageType.EXCEPTION
logging.exception(ex)
result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error')
oprot.writeMessageBegin("create", msg_type, seqid)
result.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()