问题
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