0
0
Flaskframework~10 mins

Calling tasks asynchronously 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 the Celery class for asynchronous tasks.

Flask
from celery import [1]
Drag options to blanks, or click blank then click option'
Aapp
BTask
CAsyncResult
DCelery
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'Task' instead of 'Celery'.
Using 'app' which is not a class to import.
Confusing 'AsyncResult' with the Celery class.
2fill in blank
medium

Complete the code to create a Celery app with the name 'myapp'.

Flask
celery_app = [1]('myapp')
Drag options to blanks, or click blank then click option'
ACelery
BTask
CAsyncResult
DFlask
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Task' which is for defining tasks, not creating the app.
Using 'Flask' which is unrelated to Celery app creation.
Using 'AsyncResult' which is for checking task status.
3fill in blank
hard

Fix the error in the task decorator to define an asynchronous task.

Flask
@celery_app.[1]
Drag options to blanks, or click blank then click option'
Arun
Bexecute
Ctask
Dasync
Attempts:
3 left
💡 Hint
Common Mistakes
Using '@celery_app.run' which does not exist.
Using '@celery_app.async' which is a reserved keyword.
Using '@celery_app.execute' which is not a decorator.
4fill in blank
hard

Fill both blanks to call the asynchronous task named 'add' with arguments 4 and 6.

Flask
result = add.[1]([2], 6)
Drag options to blanks, or click blank then click option'
Adelay
Bapply_async
C4
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'apply_async' without correct argument format.
Passing 5 instead of 4 as the first argument.
Calling the task directly without delay or apply_async.
5fill in blank
hard

Fill all three blanks to check if the asynchronous task result is ready and get the result.

Flask
if result.[1]():
    value = result.[2]()
else:
    value = [3]
Drag options to blanks, or click blank then click option'
Aready
Bget
CNone
Dstatus
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'status' instead of 'ready' to check completion.
Using 'ready' instead of 'get' to retrieve the result.
Assigning a wrong default value instead of None.