本文整理汇总了Python中thrift.Thrift.TApplicationException类的典型用法代码示例。如果您正苦于以下问题:Python TApplicationException类的具体用法?Python TApplicationException怎么用?Python TApplicationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TApplicationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_annotate
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()
示例2: recv_Log
def recv_Log(self, iprot, mtype, rseqid):
"""
Called when the result of the log request was received.
"""
if mtype == TMessageType.EXCEPTION:
result = TApplicationException()
else:
result = scribe.Log_result()
result.read(iprot)
iprot.readMessageEnd()
try:
d = self._reqs.pop(rseqid)
except KeyError:
log.err(result, "Unexpected log result")
if isinstance(result, Exception):
d.errback(result)
elif result.success is not None:
d.callback(result.success)
else:
d.errback(TApplicationException(
TApplicationException.MISSING_RESULT,
'Log failed: unknown result'))
示例3: _handle_request
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)
示例4: process_create
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()
示例5: process_postSnsInvitationMessage
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()
示例6: process_similar
def process_similar(self, seqid, iprot, oprot):
args = similar_args()
args.read(iprot)
iprot.readMessageEnd()
result = similar_result()
try:
result.success = self._handler.similar(args.query, args.n, args.sorting)
msg_type = TMessageType.REPLY
except TTransport.TTransportException:
raise
except TSearchException as error:
msg_type = TMessageType.REPLY
result.error = error
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("similar", msg_type, seqid)
result.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()
示例7: process_fetchMessageOperations
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()
示例8: write_results_after_future
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)
示例9: process_ping
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()
示例10: process_retrieveRequestToken
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()
示例11: process_getLocalAssignmentForStorm
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()
示例12: process_sendChatCheckedByWatermark
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()
示例13: process_notifyLeaveRoom
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()
示例14: process_getBotUseInfo
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()
示例15: process_getCapabilities
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()