Bird
0
0

A developer uses @background decorator but the task runs immediately instead of in background. What is the likely mistake?

medium📝 Debug Q7 of 15
Django - Celery and Background Tasks
A developer uses @background decorator but the task runs immediately instead of in background. What is the likely mistake?
AThey called the function instead of queuing it
BThey forgot to import the decorator
CThey used the wrong Python version
DThey did not restart the Django server
Step-by-Step Solution
Solution:
  1. Step 1: Understand @background decorator usage

    The decorated function should be called with .delay() or similar to queue it.
  2. Step 2: Identify common misuse

    Calling the function directly runs it immediately, ignoring background behavior.
  3. Final Answer:

    They called the function instead of queuing it -> Option A
  4. Quick Check:

    Call background tasks properly to queue = A [OK]
Quick Trick: Use .delay() or equivalent to queue decorated tasks [OK]
Common Mistakes:
MISTAKES
  • Calling decorated function directly
  • Ignoring decorator import errors
  • Blaming Python version or server restart

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes