Bird
0
0

Given this Flask and Celery setup, what will be the output when calling add.delay(4, 5)?

medium📝 state output Q4 of 15
Flask - Background Tasks
Given this Flask and Celery setup, what will be the output when calling add.delay(4, 5)?
from celery import Celery
celery = Celery(__name__, broker='redis://localhost:6379/0')
@celery.task
def add(x, y):
    return x + y
result = add.delay(4, 5)
print(type(result))
A9
B<class 'celery.result.AsyncResult'>
C<class 'int'>
DNone
Step-by-Step Solution
Solution:
  1. Step 1: Understand what delay() returns

    The delay() method sends the task asynchronously and returns an AsyncResult object immediately.
  2. Step 2: Identify the printed type

    Printing type(result) shows the AsyncResult class, not the task result value.
  3. Final Answer:

    <class 'celery.result.AsyncResult'> -> Option B
  4. Quick Check:

    delay() returns AsyncResult, not direct result [OK]
Quick Trick: delay() returns AsyncResult object, not task output [OK]
Common Mistakes:
MISTAKES
  • Expecting immediate task result
  • Confusing AsyncResult with int
  • Assuming print shows task return value

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes