Recall & Review
beginner
What does it mean to call a task asynchronously in Flask?
Calling a task asynchronously means starting it to run in the background without making the user wait for it to finish. The main program continues working while the task runs separately.
Click to reveal answer
beginner
Which Flask extension is commonly used to run tasks asynchronously?
Flask uses Celery, a task queue, to run tasks asynchronously. Celery lets you send tasks to workers that run them outside the main Flask app.
Click to reveal answer
beginner
How do you start a Celery task asynchronously in Flask?
You call the task's
delay() method. For example, my_task.delay(args) sends the task to run in the background immediately.Click to reveal answer
beginner
Why should long-running tasks be run asynchronously in a web app?
Long tasks can slow down the app and make users wait. Running them asynchronously keeps the app responsive and improves user experience.
Click to reveal answer
beginner
What is a common real-life example of an asynchronous task in Flask?
Sending emails after a user signs up is a common async task. The app sends the email in the background so the user doesn’t wait on the signup page.
Click to reveal answer
Which method is used to call a Celery task asynchronously in Flask?
✗ Incorrect
The delay() method sends the task to the Celery worker to run asynchronously.
Why use asynchronous tasks in a Flask web app?
✗ Incorrect
Asynchronous tasks let the app stay responsive by running long tasks in the background.
Which Flask extension helps manage asynchronous tasks?
✗ Incorrect
Celery is the popular extension used for asynchronous task queues in Flask.
What happens if you call a long task synchronously in Flask?
✗ Incorrect
Synchronous calls block the app, making the user wait for the task to finish.
Which of these is a good candidate for an asynchronous task?
✗ Incorrect
Sending emails is often slow and done asynchronously to avoid blocking the user.
Explain how you would set up and call an asynchronous task in a Flask app using Celery.
Think about how Flask and Celery work together to run background jobs.
You got /4 concepts.
Describe why asynchronous tasks improve user experience in web applications.
Consider what happens when a task takes a long time to finish.
You got /4 concepts.