Creating Asynchronous Tasks With Celery and Django (Summary)
After you’ve integrated Celery and refactored your Django code, sending feedback in your app is such a great experience that you don’t want to stop sending positive feedback messages!
Handling long-running or compute-expensive tasks asynchronously in the background with Celery, instead of bogging down your web app with tasks that it wasn’t intended to handle, can breathe fresh air into a slow-running application.
Celery aims to provide a quick interface for sending messages to its distributed task queue. In this example, you experienced how little you might need to change to use Celery in your Django app.
In this video course, you learned how to:
- Recognize effective use cases for Celery
- Differentiate between Celery beat and Celery workers
- Integrate Celery and Redis in a Django project
- Set up asynchronous tasks that run independently of your Django app
- Refactor Django code to run a task with Celery instead
Keep identifying any tasks that Django doesn’t need to handle. Then offload them to your favorite distributed task queue instead.
Knowing that you can handle sluggish tasks in the background without impairing your user experience also opens up doors to new ideas:
- Implement automatic spam filtering on your feedback submissions so you don’t have to waste time sifting through spammy emails.
- Translate the text of all feedback submissions to Spanish so you can add new vocabulary to your flashcards app and aid your language study.
- Identify tasks in your own Django projects that you can offload to Celery workers.
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.
00:00 Summary, well done. You’ve made it to the end of the course. Now you’ve integrated Celery and refactored your Django code. Sending feedback in your app is smooth and quick, handling long-running, or compute-intensive tasks asynchronously in the background with Celery.
00:16 Instead of bogging down the web app with them, can breathe fresh air into a slow-running application.
00:22 Celery aims to provide a quick interface for sending messages to its distributed task queue. Here you experienced how little you might need to change to use Celery in your Django app.
00:33 In this course, you learned how to recognize effective use cases for Celery, differentiate between Celery Beat and Celery workers. Integrate Celery and Redis into a Django project.
00:46 Set up asynchronous tasks that run independently of your Django app and refactor Django code to run a task with Celery instead.
00:56 In the future, you can keep identifying any task that Django doesn’t need to handle and offload them to your favorite distributed task queue. Instead, with Celery as your ally, you can start integrating more features into your web app, let a distributed task queue.
01:10 Run these tasks asynchronously in the background.
01:13 We hope you found this course useful, and we’ll see you again soon at realpython.com.
Become a Member to join the conversation.
danilolimadutra on March 24, 2024
For anyone who want to run this project in docker, follow the files.
Dockerfile
docker-compose.yaml
requirements.txt