Bird
0
0

Identify the error in this Celery Beat configuration:

medium📝 Debug Q14 of 15
Flask - Background Tasks
Identify the error in this Celery Beat configuration:
beat_schedule = {
'task1': {
'task': 'app.task1',
'schedule': crontab(minute='*/5')
},
'task2': {
'task': 'app.task2',
'schedule': '10',
}
}
AThe dictionary keys 'task1' and 'task2' must be integers
B'task' names must be functions, not strings
CMissing import for crontab causes runtime error
D'schedule' for 'task2' should be an integer or crontab, not a string
Step-by-Step Solution
Solution:
  1. Step 1: Check 'schedule' types

    For 'task1', schedule uses crontab correctly. For 'task2', schedule is a string '10', which should be an integer 10 or a crontab object.
  2. Step 2: Validate other parts

    Task names as strings are correct references. Import errors are not shown here. Dictionary keys can be strings.
  3. Final Answer:

    'schedule' for 'task2' should be an integer or crontab, not a string -> Option D
  4. Quick Check:

    Schedule must be int or crontab, not string [OK]
Quick Trick: Schedule values must be int or crontab, not quoted strings [OK]
Common Mistakes:
MISTAKES
  • Using string instead of int for schedule interval
  • Confusing task names with function objects
  • Assuming dictionary keys must be integers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes