lajarre
lajarre

Reputation: 5162

Celery tasks functions - web server vs remote server

I'm willing to send tasks from a web server (running Django) to a remote machine that is holding a Rabbitmq server and some workers that I implemented with Celery.

If I follow the Celery way to go, it seems I have to share the code between both machines, which means replicating the workers logic code in the web app code.

So:

Upvotes: 2

Views: 773

Answers (2)

ant31
ant31

Reputation: 4760

You can use send_task. It takes same parameters than apply_async but you only have to give the task name. Without loading the module in django you can send tasks:

app.send_task('tasks.add', args=[2, 2], kwargs={})

http://celery.readthedocs.org/en/latest/reference/celery.html#celery.Celery.send_task

Upvotes: 3

dm03514
dm03514

Reputation: 55952

One way to manage this is to store your workers in your django project. Django and celery play nice to each other allowing you to use parts of your django project in your celery app. http://celery.readthedocs.org/en/latest/django/first-steps-with-django.html

Deploying this would mean that your web application would not use the modules involved with your celery workers, and on your celery machine your django views and such would never be used. This usually only results in a couple of megs of unused django application code...

Upvotes: 2

Related Questions