Complete the code to call the Celery task asynchronously.
from tasks import send_email send_email.[1]()
In Django with Celery, calling delay() on a task sends it to the queue to run asynchronously.
Complete the code to import the Celery app instance correctly.
from [1] import app as celery_app
In Django projects, the Celery app is usually defined in myproject/celery.py. Importing it as myproject.celery is the correct way.
Fix the error in the code to schedule a task with arguments asynchronously.
send_email.[1](user_id=42, subject='Hello')
The apply_async() method schedules a task with arguments asynchronously in Celery.
Fill both blanks to create a periodic task using Celery beat.
from celery.schedules import [1] app.conf.beat_schedule = { 'send-report-every-day': { 'task': 'tasks.send_report', 'schedule': [2](hours=24), }, }
To schedule periodic tasks, Celery beat uses interval imported from celery.schedules for repeating intervals, e.g., interval(hours=24).
Fill all three blanks to retry a failed task after 10 seconds.
@app.task(bind=True, max_retries=3) def send_notification(self, user_id): try: # send notification logic pass except Exception as exc: raise self.[1](exc, countdown=[2]) from exc # Call the task send_notification.[3](user_id=5)
The retry method retries the task after a delay specified by countdown. The task is called asynchronously with delay().