0
0
Flaskframework~10 mins

Periodic tasks with Celery Beat in Flask - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import Celery in a Flask app.

Flask
from celery import [1]
Drag options to blanks, or click blank then click option'
Acelery_app
Bcelery
CCeleryApp
DCelery
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'celery' which is incorrect.
Using names like 'CeleryApp' which do not exist.
2fill in blank
medium

Complete the code to create a Celery instance with Flask app name.

Flask
celery = Celery([1])
Drag options to blanks, or click blank then click option'
Aapp
B'myapp'
C'celery'
D'flaskapp'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the Flask app object instead of its name as a string.
Using incorrect string names.
3fill in blank
hard

Fix the error in the Celery configuration dictionary key for broker URL.

Flask
celery.conf.update({ 'broker_[1]': 'redis://localhost:6379/0' })
Drag options to blanks, or click blank then click option'
Aurl
Buri
Caddress
Dlink
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'broker_uri' which is incorrect.
Using 'broker_address' or 'broker_link' which are invalid keys.
4fill in blank
hard

Fill both blanks to schedule a periodic task every 10 seconds using Celery Beat.

Flask
from celery.schedules import [1]
celery.conf.beat_schedule = {
    'task-every-10-seconds': {
        'task': 'tasks.my_task',
        'schedule': [2](10.0),
    },
}
Drag options to blanks, or click blank then click option'
Acrontab
Btimedelta
Cschedule
Dinterval
Attempts:
3 left
💡 Hint
Common Mistakes
Using crontab for seconds interval which is for cron-like schedules.
Using timedelta which is not a Celery schedule.
5fill in blank
hard

Fill all three blanks to define a Celery task function that prints 'Hello' every minute.

Flask
@celery.task
async def [1]():
    print([2])

celery.conf.beat_schedule = {
    'hello-every-minute': {
        'task': '[3]',
        'schedule': interval(60.0),
    },
}
Drag options to blanks, or click blank then click option'
Ahello_task
B'Hello'
D'hello_task'
Attempts:
3 left
💡 Hint
Common Mistakes
Using mismatched task names between function and schedule.
Forgetting quotes around the string to print.