0
0
Flaskframework~5 mins

Periodic tasks with Celery Beat in Flask - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is Celery Beat in the context of Celery?
Celery Beat is a scheduler that kicks off tasks at regular intervals, which are then executed by Celery workers. It helps automate periodic tasks like sending emails or cleaning databases.
Click to reveal answer
intermediate
How do you define a periodic task using Celery Beat in Flask?
You define periodic tasks by adding a schedule to Celery Beat's configuration, usually in the 'beat_schedule' dictionary, specifying the task name, the function to call, and the interval or crontab timing.
Click to reveal answer
beginner
What is the role of the 'beat_schedule' setting in Celery Beat?
'beat_schedule' is a dictionary where each key is a task name and the value defines when and how often the task runs, using intervals or crontab expressions.
Click to reveal answer
beginner
Why do you need to run both Celery worker and Celery Beat for periodic tasks?
Celery Beat only schedules tasks but does not execute them. The Celery worker listens for tasks and runs them. Both must run simultaneously for periodic tasks to work.
Click to reveal answer
beginner
How can you test if your periodic task with Celery Beat is working correctly?
You can check the Celery worker logs to see if the task runs at the scheduled times, or add print/log statements inside the task function to confirm execution.
Click to reveal answer
What does Celery Beat do in a Flask app?
ASchedules tasks to run periodically
BExecutes tasks immediately
CStores task results
DManages database connections
Which configuration dictionary holds periodic task schedules in Celery Beat?
Aworker_concurrency
Btask_routes
Cbeat_schedule
Dbroker_url
To run periodic tasks, you must start:
ABoth Celery Beat and Celery worker
BOnly Celery worker
COnly Celery Beat
DNeither, tasks run automatically
Which of these can you use to specify task timing in Celery Beat?
ACSS selectors
BSQL query
CHTML tags
Dcrontab
How can you confirm a periodic task ran successfully?
ARestart the Flask app
BCheck Celery worker logs
CDelete the task
DChange the broker URL
Explain how Celery Beat and Celery worker work together to run periodic tasks in a Flask app.
Think about who plans the task and who actually does it.
You got /4 concepts.
    Describe how to set up a simple periodic task using Celery Beat in Flask.
    Start from writing the task to running the scheduler and worker.
    You got /4 concepts.