Could someone please clarify the task priority usage in Celery tasks?

こ雲淡風輕ζ 提交于 2020-03-01 02:34:00

问题


The documentation says very little about the priority attribute. One of the rare documentation references says the following:

priority (int): The task priority, a number between 0 and 9.
  Defaults to the :attr:`priority` attribute.

(Ref: http://docs.celeryproject.org/en/latest/_modules/celery/app/task.html#Task.apply_async )

However, if you go to the bottom of the following page - http://docs.celeryproject.org/en/latest/userguide/calling.html - you will see:

priority A number between 0 and 255, where 255 is the highest priority.

Supported by: RabbitMQ, Redis (priority reversed, 0 is highest).

These two pieces of information contradict. Also, I would assume that the docstring is more up-to-date...

Question is which one is relevant, and more importantly: How are priorities ordered - does priority=0 mean highest priority, or not? Or it depends on the backend, as the docs page says...

I've also made a GitHub issue for this - https://github.com/celery/celery/issues/4599

Update 1: I have found the following in the kombu changelog for v4.0 (http://docs.celeryproject.org/projects/kombu/en/latest/changelog.html):

Redis: Priority 0 is now lowest, 9 is highest. (backward incompatible)

This to match how priorities in AMQP works.

Fix contributed by Alex Koshelev.

来源:https://stackoverflow.com/questions/49319834/could-someone-please-clarify-the-task-priority-usage-in-celery-tasks

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