Celery - How to send task from remote machine?

前端 未结 4 1880
庸人自扰
庸人自扰 2021-01-31 16:42

We have a server running celery workers and a Redis queue. The tasks are defined on that server.
I need to be able to call these tasks from a remote machine.
I know that

4条回答
  •  长情又很酷
    2021-01-31 17:12

    This may be a way: Creating a Celery object and using send_task from that object, the object can have the configuration to find the broker.

    from celery import Celery
    celery = Celery()
    celery.config_from_object('celeryconfig')
    celery.send_task('tasks.add', (2,2))
    

    celeryconfig is a file containing the celery configuration, there are other ways set config on the celery object.

提交回复
热议问题