Capture the exception that caused the task to be retried, if any.

def on_retry(self, exc, task_id, args, kwargs, einfo):
        """
        Capture the exception that caused the task to be retried, if any.
        """
        super(LoggedTask, self).on_retry(exc, task_id, args, kwargs, einfo)
        log.warning('[{}] retried due to {}'.format(task_id, getattr(einfo, 'traceback', None)))