Bird
0
0

Given the code:

medium📝 state output Q13 of 15
Django - Celery and Background Tasks
Given the code:
result = AsyncResult('abc123')
status = result.status
output = result.result

What will status and output represent if the task is still running?
A<code>status</code> is 'PENDING', <code>output</code> is None
B<code>status</code> is 'RUNNING', <code>output</code> is None
C<code>status</code> is 'FAILURE', <code>output</code> is the error info
D<code>status</code> is 'SUCCESS', <code>output</code> is the task result
Step-by-Step Solution
Solution:
  1. Step 1: Understand AsyncResult status values

    By default, while a task is running without calling update_state inside the task, result.status remains 'PENDING'.
  2. Step 2: Check result property during running

    result.result returns None until the task completes.
  3. Final Answer:

    status is 'PENDING', output is None -> Option A
  4. Quick Check:

    Running task (default): status='PENDING', result=None [OK]
Quick Trick: Default running tasks show status 'PENDING' and result None [OK]
Common Mistakes:
MISTAKES
  • Mistaking for 'RUNNING' status (doesn't exist)
  • Confusing with 'STARTED' which requires explicit update_state
  • Thinking result is available before completion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes