Bird
0
0

How can you dynamically change a periodic task's schedule at runtime with Celery Beat?

hard📝 Application Q9 of 15
Django - Celery and Background Tasks
How can you dynamically change a periodic task's schedule at runtime with Celery Beat?
AChange the task function code and redeploy the app
BModify the beat_schedule dictionary in settings.py and reload Django server
CUpdate the schedule in the Django database and restart Celery Beat
DSend a special message to Celery worker to update schedule
Step-by-Step Solution
Solution:
  1. Step 1: Understand dynamic schedule storage

    Using Django database-backed scheduler allows runtime updates without code changes.
  2. Step 2: Recognize limitations of static config

    Changing settings.py requires restart; task code changes don't affect schedule; no message updates schedule.
  3. Final Answer:

    Update the schedule in the Django database and restart Celery Beat -> Option C
  4. Quick Check:

    Dynamic schedule = DB update + Beat restart [OK]
Quick Trick: Use DB-backed scheduler to change schedules without code edits [OK]
Common Mistakes:
MISTAKES
  • Editing settings.py for dynamic changes
  • Thinking task code changes affect schedule
  • Believing workers can update schedules via messages

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes