Celery has an architecture based on pluggable components and a mechanism of message exchange that uses a protocol according to a selected message transport (broker). This is illustrated in the following diagram:
Now, let us go through each item within Celery's architecture in detail.
The client components, as presented in the previous diagram, have the function of creating and dispatching tasks to the brokers.
We will now analyze a code example that demonstrates the definition of a task by using the @app.task
decorator, which is accessible through an instance of Celery application that, for now, will be called app
. The following code example demonstrates a simple Hello World
app:
@app.task def hello_world(): return "Hello I'm a celery task"
As we mentioned earlier, there are several types of tasks: synchronous, asynchronous, periodic, and scheduled. When we perform a task call, it returns...