File: tasks.py

package info (click to toggle)
celery-progress 0.1.1-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 156 kB
  • sloc: python: 272; javascript: 168; makefile: 6
file content (11 lines) | stat: -rw-r--r-- 441 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
from celery.signals import task_postrun


@task_postrun.connect(retry=True)
def task_postrun_handler(**kwargs):
    """Runs after a task has finished. This will update the result backend to include the IGNORED result state.

    Necessary for HTTP to properly receive ignored task event."""
    if kwargs.pop('state') == 'IGNORED':
        task = kwargs.pop('task')
        task.update_state(state='IGNORED', meta=str(kwargs.pop('retval')))