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 tasks.py


from time import sleep
from celery import Celery

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


@app.task
def add(x, y):
sleep(4)
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)






Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm