librelist archives

« back to archive

Flask-Exceptional gets a direct publish() method

Flask-Exceptional gets a direct publish() method

From:
Jonathan Zempel
Date:
2011-11-10 @ 16:55
If you're using the Flask-Exceptional extension, you may be interested to
know that the new version 0.4.7 adds the ability to directly publish an
exception outside the context of a request. This is interesting if, for
example, you're using Celery and want to track when there is an error
inside your queue process. Just hook into Celery's task_failure signal,
like this:


from celery.signals import task_failure
from flask.ext.exceptional import Exceptional
from werkzeug.debug.tbtools import Traceback

def task_failure_handler(signal, sender, **kwargs):
    exception = kwargs["exception"]
    traceback = Traceback(type(exception), exception, kwargs["traceback"])
    Exceptional.publish(<your_config>, traceback)

task_failure.connect(task_failure_handler)


Obviously, this is just one example of the many ways you can benefit from
publishing direct to Exceptional. If you aren't using Exceptional, check it
out. It's a worthwhile service (www.getexceptional.com) from a responsive
team. If you start using the publish() method in Flask-Exceptional, please
 send me your issues or feedback.

Cheers,
Jonathan.