Bird
0
0

Which of the following is the correct way to define a Celery task in Flask?

easy📝 Syntax Q12 of 15
Flask - Background Tasks
Which of the following is the correct way to define a Celery task in Flask?
A@celery_app.task def my_task(): pass
Bcelery_app.run_task(my_task)
C@app.route('/task') def my_task(): pass
Ddef my_task(): pass
Step-by-Step Solution
Solution:
  1. Step 1: Identify the decorator for Celery tasks

    The correct decorator to define a Celery task is @celery_app.task.
  2. Step 2: Check syntax correctness

    @celery_app.task def my_task(): pass correctly uses @celery_app.task above the function definition.
  3. Final Answer:

    @celery_app.task\ndef my_task(): pass -> Option A
  4. Quick Check:

    Use @celery_app.task to define tasks [OK]
Quick Trick: Look for @celery_app.task decorator above function [OK]
Common Mistakes:
MISTAKES
  • Using Flask route decorator instead of Celery task
  • Calling run_task instead of using decorator
  • Defining function without decorator

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes