Вопрос

I am looking for ways to reduce error-log clutter.

One of the most frustrating use-cases for "wasteful exception logging" is when failing taskqueue tasks.

Of course, a good solution for that particular example is to self.error(500) instead of raise Exception - but this solution does not work for deferred.defer.

The only way that I know to retrigger a deferred task is to raise an Exception through to the webapp handler.

The documented solution looks like the following:

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()

Other than moving my solution to the taskqueue over deferred.defer - what solutions exist?

Это было полезно?

Решение

add_flow_exception is only an NDB thing, it's not hooked into anything higher-level, so unless it's code inside a tasklet raising the exception, I don't think it can help you.

From a deferred function, you can raise deferred.SingularTaskFailure to avoid the logging.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top