Bird
0
0

Consider this Celery task:

medium📝 component behavior Q5 of 15
Flask - Background Tasks
Consider this Celery task:
@celery_app.task
def add(x, y):
    return x + y

What happens if you call add.apply_async(args=(2, 3), countdown=10)?
AThe task is scheduled but never executed.
BThe task will execute after a 10-second delay.
CIt raises an error because countdown is invalid.
DThe task executes immediately ignoring countdown.
Step-by-Step Solution
Solution:
  1. Step 1: Understand apply_async with countdown

    The countdown argument delays task execution by given seconds.
  2. Step 2: Confirm behavior

    Calling add.apply_async(args=(2, 3), countdown=10) schedules the task to run after 10 seconds.
  3. Final Answer:

    The task will execute after a 10-second delay. -> Option B
  4. Quick Check:

    apply_async with countdown delays task [OK]
Quick Trick: Use apply_async(countdown=seconds) to delay tasks [OK]
Common Mistakes:
MISTAKES
  • Assuming countdown is ignored
  • Thinking countdown causes error
  • Believing task never runs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes