@task_failure.connect
def process_failure_signal(exception, traceback, sender, task_id, signal, args, kwargs, einfo, **kw):
 exc_info = (type(exception), exception, traceback)
 log.error(u'Celery TASK exception: {0.__name__}: {1}'.format(*exc_info), exc_info=exc_info, extra={'data': {'task_id': task_id, 'sender': sender, 'args': args, 'kwargs': kwargs}})

@ task_failure . connect def process_failure_signal ( exception , traceback , sender , task_id , signal , args , kwargs , einfo , ** kw ) : exc_info = ( type ( exception ) , exception , traceback ) log . error ( u'Celery TASK exception: {0.__name__}: {1}' . format ( * exc_info ) , exc_info = exc_info , extra = { 'data' : { 'task_id' : task_id , 'sender' : sender , 'args' : args , 'kwargs' : kwargs } } )
catch any task failure signals from within our worker processes and log them as exceptions .