0
0
Djangoframework~20 mins

Periodic tasks with Celery Beat in Django - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Celery Beat Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
1:30remaining
What happens when a periodic task is scheduled with Celery Beat?
Consider a Django project using Celery and Celery Beat. If you schedule a periodic task to run every 10 minutes, what will Celery Beat do?
ACelery Beat only logs the task schedule but does not trigger any execution.
BCelery Beat sends a message to the Celery worker every 10 minutes to execute the task.
CCelery Beat stores the task results every 10 minutes but does not trigger execution.
DCelery Beat runs the task itself every 10 minutes without involving Celery workers.
Attempts:
2 left
💡 Hint
Think about how Celery Beat interacts with Celery workers to run tasks.
📝 Syntax
intermediate
1:30remaining
Which Celery Beat schedule syntax correctly runs a task every hour?
Given the following Celery Beat schedule snippet, which option correctly schedules a task to run every hour?
Django
from celery.schedules import crontab

CELERY_BEAT_SCHEDULE = {
    'task-every-hour': {
        'task': 'myapp.tasks.my_task',
        'schedule': ???
    }
}
Acrontab(minute=0, hour='*')
Bcrontab(minute='*', hour=0)
Ccrontab(minute=0, hour=0)
Dcrontab(minute='0', hour='0-59')
Attempts:
2 left
💡 Hint
An hourly task runs at minute 0 of every hour.
🔧 Debug
advanced
2:00remaining
Why does a periodic task not run even though Celery Beat is running?
You have Celery Beat running and a periodic task scheduled. However, the task never executes. Which of the following is the most likely cause?
AThe periodic task schedule is set to a past date.
BCelery Beat is running with the wrong timezone setting.
CThe task function is missing a @shared_task decorator.
DCelery worker is not running or not connected to the message broker.
Attempts:
2 left
💡 Hint
Celery Beat only sends messages; workers must be ready to receive them.
state_output
advanced
1:30remaining
What is the state of a periodic task after Celery Beat triggers it?
When Celery Beat triggers a periodic task, what is the expected state of the task in Celery's task monitoring system immediately after triggering?
AThe task state is 'PENDING' until a worker picks it up.
BThe task state is 'STARTED' immediately after Celery Beat triggers it.
CThe task state is 'RETRY' until the task completes.
DThe task state is 'SUCCESS' immediately after Celery Beat triggers it.
Attempts:
2 left
💡 Hint
Think about when the task actually starts running.
🧠 Conceptual
expert
2:30remaining
How does Celery Beat ensure periodic tasks run on schedule in a distributed system?
In a distributed Django application with multiple Celery Beat instances running for redundancy, how does Celery Beat prevent the same periodic task from running multiple times simultaneously?
ACelery Beat instances communicate over the network to elect a leader manually.
BEach Celery Beat instance runs the task independently, and Celery workers deduplicate tasks.
CCelery Beat uses a distributed lock in the message broker or database to allow only one scheduler to send task messages.
DCelery Beat disables periodic tasks on all but one instance automatically.
Attempts:
2 left
💡 Hint
Think about how distributed systems avoid duplicate work.