python celery first steps

If you follow python celery first step from the official site, you probably gonna get some heart attack trying to get it work.

Please use the following docker command :

docker run -d -p 5672:5672 rabbitmq

First you need to tell celery, which method you would like to register. This allows celery to provide task registration and execution to.

This is an example of

from time import sleep
from celery import Celery

app = Celery('tasks', broker='amqp://guest:guest@localhost:5672')

def add(x, y):
print("executing stuff")
return x + y

Now that you have it registered, next is to run it. This queue "add" task (defined earlier) and put it into motion.

from tasks import add

add.delay(4, 4)


Popular posts from this blog

Solving Sonarqube :- Project was never analyzed. A regular analysis is required before a branch analysis

spark - pyspark reading from excel files