Can celery assign task to specify worker

陌路散爱 提交于 2019-12-21 10:50:09

问题


Celery will send task to idle workers.

I have a task will run every 5 seconds, and I want this task to only be sent to one specify worker.

Other tasks can share the left over workers

Can celery do this??

And I want to know what this parameter is: CELERY_TASK_RESULT_EXPIRES
Does it means that the task will not be sent to a worker in the queue?
Or does it stop the task if it runs too long?


回答1:


Sure, you can. Best way to do it, separate celery workers using different queues. You just need to make sure that task you need goes to separate queue, and your worker listening particular queue. Long story for this: http://docs.celeryproject.org/en/latest/userguide/routing.html




回答2:


Just to answer your second question CELERY_TASK_RESULT_EXPIRES is the time in seconds that the result of the task is persisted. So after a task is over, its result is saved into your result backend. The result is kept there for the amount of time specified by that parameter. That is used when a task result might be accessed by different callers.

This has probably nothing to do with your problem. As for the first solution, as already stated you have to use multiple queues. However be aware that you cannot assign the task to a specific Worker Process, just to a specific Worker which will then assign it to a specific Worker Process.



来源:https://stackoverflow.com/questions/34468024/can-celery-assign-task-to-specify-worker

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!