Bird
0
0

What will happen if you call a Celery task synchronously using task.delay() in Flask?

medium📝 component behavior Q5 of 15
Flask - Background Tasks
What will happen if you call a Celery task synchronously using task.delay() in Flask?
AThe task runs immediately and blocks the request until done.
BThe task runs asynchronously in the background.
CThe task is queued but never executed.
DThe Flask app crashes with an error.
Step-by-Step Solution
Solution:
  1. Step 1: Understand Celery's delay() method

    Calling task.delay() sends the task to the queue to run asynchronously.
  2. Step 2: Confirm behavior in Flask

    The Flask app continues without waiting; the task runs in the background worker.
  3. Final Answer:

    The task runs asynchronously in the background. -> Option B
  4. Quick Check:

    task.delay() = async background execution [OK]
Quick Trick: Use task.delay() to run Celery tasks async [OK]
Common Mistakes:
MISTAKES
  • Thinking delay() runs task immediately
  • Assuming delay() blocks Flask request
  • Believing delay() causes app crash

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes