Skip to content
Myr

tasks.py

This file

Path

examples/celery/src/task_app/tasks.py

23 lines · 484 bytes · Python

Last changed by

Merge branch '2.2.x'David Lordbefore adoptiona18ae3d

History of this file

Take it

Merge branch '2.2.x'David Lordbefore adoptiona18ae3d

lines 1–23why, one step back
1import time
23from celery import shared_task4from celery import Task567@shared_task(ignore_result=False)8def add(a: int, b: int) -> int:9 return a + b101112@shared_task()13def block() -> None:14 time.sleep(5)151617@shared_task(bind=True, ignore_result=False)18def process(self: Task, total: int) -> object:19 for i in range(total):20 self.update_state(state="PROGRESS", meta={"current": i + 1, "total": total})21 time.sleep(1)2223 return {"current": total, "total": total}