【发布时间】:2014-04-24 16:58:24
【问题描述】:
我正在寻找减少错误日志混乱的方法。
“浪费性异常日志记录”最令人沮丧的用例之一是任务队列任务失败。
当然,对于该特定示例,一个好的解决方案是 self.error(500) 而不是 raise Exception - 但此解决方案不适用于 deferred.defer。
我知道重新触发延迟任务的唯一方法是将Exception 提高到 webapp 处理程序。
记录的解决方案如下所示:
class CompletedExpectedException(Exception):
"""This Exception is completely expected.
We don't need to see it as "errors" in the logs, or GAE dashboard graphs."""
pass
# The following code, when on the 'global' app level, does not have an effect.
ndb.add_flow_exception(CompletedExpectedException)
# The following code does not work, either
class WarmupHandler(webapp2.RequestHandler):
"""/_ah/warmup or /_ah/start"""
def get(self):
ndb.add_flow_exception(CompletedExpectedException)
def post(self):
self.get()
除了将我的解决方案移至taskqueue 而不是deferred.defer - 还有哪些解决方案?
【问题讨论】:
标签: python google-app-engine app-engine-ndb