Celery is a task queue for Python. There used to be an extension to integrate Flask and Celery, but with Celery 3.0, it became obsolete. Now, Celery can be directly used with Flask by just using a bit of configuration. In the Understanding asynchronous operations recipe, we implemented asynchronous processing to send an email. In this recipe, we will implement the same using Celery.
Working with Celery
Getting ready
Celery can be installed simply from PyPI:
$ pip install celery
To make Celery work with Flask, we will need to modify our Flask app config file a bit. Here, we will use Redis as the broker (thanks to its simplicity).
Make sure that you run the Redis server for the connection to happen. To install and run a Redis...