Understanding Celery tasks
Celery is a non-blocking task queue that runs on a distributed system. It can manage asynchronous background processes that are huge and heavy with CPU workloads. It is a third-party tool, so we need to install it first through pip
:
pip install celery
It schedules and runs tasks concurrently on a single server or distributed environment. But it requires a message transport to send and receive messages, such as Redis, an in-memory database that can be used as a message broker for messages in strings, dictionaries, lists, sets, bitmaps, and stream types. Also, we can install Redis on Linux, macOS, and Windows. Now, after the installation, run its redis-server.exe
command to start the server. In Windows, the Redis service is set to run by default after installation, which causes a TCP bind listener error. So, we need to stop it before running the startup command. Figure 8.1 shows Windows Task Manager with the Redis service giving a Stopped status: