Bird
0
0

Given this Celery task:

medium📝 component behavior Q4 of 15
Django - Celery and Background Tasks
Given this Celery task:
@shared_task
def multiply(x, y):
    return x * y
What will result = multiply.delay(3, 4) return?
AA syntax error because delay() is not valid
BAn AsyncResult object representing the task execution
CThe integer 12 immediately
DNone, because the task runs in background
Step-by-Step Solution
Solution:
  1. Step 1: Understand what delay() returns

    Calling delay() on a Celery task returns an AsyncResult object, not the task result immediately.
  2. Step 2: Check other options

    The task runs asynchronously, so the integer 12 is not returned immediately; no syntax error occurs; it does not return None.
  3. Final Answer:

    An AsyncResult object representing the task execution -> Option B
  4. Quick Check:

    delay() returns AsyncResult object [OK]
Quick Trick: delay() returns AsyncResult, not immediate result [OK]
Common Mistakes:
MISTAKES
  • Expecting immediate task result
  • Thinking delay() causes syntax error
  • Assuming delay() returns None

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes