If the task fails, persist a record of the task.

def on_failure(self, exc, task_id, args, kwargs, einfo):
        """
        If the task fails, persist a record of the task.
        """
        if not FailedTask.objects.filter(task_id=task_id, datetime_resolved=None).exists():
            FailedTask.objects.create(
                task_name=_truncate_to_field(FailedTask, 'task_name', self.name),
                task_id=task_id,  # Fixed length UUID: No need to truncate
                args=args,
                kwargs=kwargs,
                exc=_truncate_to_field(FailedTask, 'exc', repr(exc)),
            )
        super(PersistOnFailureTask, self).on_failure(exc, task_id, args, kwargs, einfo)