Bird
0
0

You want to schedule a Flask Celery task to run every Monday at 8:00 AM using Celery Beat. Which beat_schedule entry correctly achieves this?

hard📝 Conceptual Q8 of 15
Flask - Background Tasks
You want to schedule a Flask Celery task to run every Monday at 8:00 AM using Celery Beat. Which beat_schedule entry correctly achieves this?
A{'weekly_task': {'task': 'app.weekly_report', 'schedule': crontab(hour=8, minute=0, day='mon')}}
B{'weekly_task': {'task': 'app.weekly_report', 'schedule': crontab(hour=8, minute=0, day_of_week=1)}}
C{'weekly_task': {'task': 'app.weekly_report', 'schedule': crontab(hour=8, minute=0, weekday='mon')}}
D{'weekly_task': {'task': 'app.weekly_report', 'schedule': crontab(hour=8, minute=0, day_of_week='mon')}}
Step-by-Step Solution
Solution:
  1. Step 1: Understand crontab parameters

    Celery's crontab uses 'day_of_week' to specify weekdays as strings or numbers.
  2. Step 2: Validate options

    {'weekly_task': {'task': 'app.weekly_report', 'schedule': crontab(hour=8, minute=0, day_of_week='mon')}} uses 'day_of_week="mon"' which is correct; {'weekly_task': {'task': 'app.weekly_report', 'schedule': crontab(hour=8, minute=0, day_of_week=1)}} uses integer 1 (also valid but less readable); Options C and D use invalid keys.
  3. Final Answer:

    {'weekly_task': {'task': 'app.weekly_report', 'schedule': crontab(hour=8, minute=0, day_of_week='mon')}} -> Option D
  4. Quick Check:

    Use 'day_of_week' with string weekday names [OK]
Quick Trick: Use 'day_of_week' with string weekday names [OK]
Common Mistakes:
MISTAKES
  • Using invalid crontab keys like 'weekday' or 'day'
  • Confusing day_of_week with day_of_month
  • Using integers without knowing their mapping

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes