Bird
0
0

What decorator is commonly used to define a background task in Django with Celery?

easy📝 Conceptual Q11 of 15
Django - Celery and Background Tasks
What decorator is commonly used to define a background task in Django with Celery?
A@task_runner
B@shared_task
C@async_task
D@background_task
Step-by-Step Solution
Solution:
  1. Step 1: Understand task definition in Django with Celery

    Celery uses the @shared_task decorator to mark functions as tasks that can run asynchronously.
  2. Step 2: Identify the correct decorator

    Among the options, only @shared_task is the correct and standard decorator for defining tasks.
  3. Final Answer:

    @shared_task -> Option B
  4. Quick Check:

    Task decorator = @shared_task [OK]
Quick Trick: Remember: Celery tasks use @shared_task decorator [OK]
Common Mistakes:
MISTAKES
  • Using @background_task which is not a Celery decorator
  • Confusing @async_task with async/await syntax
  • Using @task_runner which is not valid in Django

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes