Celery Tasks Functions - Web Server and Remote Server

I am ready to send tasks from a web server (running Django) to the remote machine where the Rabbitmq server is located and some workers that I implemented using Celery.

If I follow the Celery path, it seems to me that I need to split the code between the two machines, which means replicating the working logic code in the web application code.

So:

  • Is there a better way to do this? Since the code is redundant, I am thinking of using the git submodule (=> replicated in the web application code repository and in the working code repository)
  • Should I better use something other than celery?
  • Did I miss something?
0
source share
2 answers

One way to manage this is to keep your employees in a django project. Django and celery blend perfectly together, allowing you to use portions of your django project in a celery app. http://celery.readthedocs.org/en/latest/django/first-steps-with-django.html

Deploying this means that your web application will not use the modules associated with your celery workers, and on your celery machine your views on django will never be used. This usually results in a few megabytes of unused django application code ...

+2
source

You can use send_task . It accepts the same parameters as apply_async, but you must specify the name of the task. Without loading the module in django, you can submit tasks:

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

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

+1
source

Source: https://habr.com/ru/post/904105/


All Articles