Issue 1:
Checklist

I have verified that the issue exists against the master branch of Celery.

This has already been asked to the discussion group first.

I have read the relevant section in the

contribution guide

on reporting bugs.

I have checked the issues list

for similar or identical bug reports.

I have checked the pull requests list

for existing proposed fixes.

I have checked the commit log

to find out if the bug was already fixed in the master branch.

I have included all related issues and possible duplicate issues

in this issue (If there are none, check this box anyway).

Mandatory Debugging Information

I have included the output of celery -A proj report in the issue.

(if you are not able to do this, then at least specify the Celery

version affected).

I have verified that the issue exists against the master branch of Celery.

I have included the contents of pip freeze in the issue.

I have included all the versions of all the external dependencies required

to reproduce this bug.

Optional Debugging Information

I have tried reproducing the issue on more than one Python version

and/or implementation.

I have tried reproducing the issue on more than one message broker and/or

result backend.

I have tried reproducing the issue on more than one version of the message

broker and/or result backend.

I have tried reproducing the issue on more than one operating system.

I have tried reproducing the issue on more than one workers pool.

I have tried reproducing the issue with autoscaling, retries,

ETA/Countdown & rate limits disabled.

I have tried reproducing the issue after downgrading

and/or upgrading Celery and its dependencies.

Related Issues and Possible Duplicates

Related Issues

None

Possible Duplicates

None

Environment & Settings

Celery version:

celery report Output:

software -> celery:4.4.5 (cliffs) kombu:4.6.10 py:3.7.5
billiard:3.6.3.0 py-amqp:2.6.0
platform -> system:Linux arch:64bit, ELF
kernel version:5.3.0-59-generic imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:amqp results:disabled

broker_url: 'amqp://guest:********@localhost:5672//'
task_default_queue: 'default'
task_queue_max_priority: 100
task_default_priority: 5
worker_prefetch_multiplier: 1
task_acks_late: True

Steps to Reproduce

Required Dependencies

Minimal Python Version: 3.7.5

Minimal Celery Version: 4.4.2 or master

Minimal Kombu Version: 4.6.10

Minimal Broker Version: rabbitmq 3.8.2

Minimal Result Backend Version: N/A

Minimal OS and/or Kernel Version: Linux-5.3.0-59-generic-x86_64-with-Ubuntu-19.10-eoan 2020-06-18 10:30:24

Minimal Broker Client Version: N/A or Unknown

Minimal Result Backend Client Version: N/A or Unknown

Python Packages

pip freeze Output:

amqp==2.6.0
billiard==3.6.3.0
celery==4.4.5
future==0.18.2
importlib-metadata==1.6.1
kombu==4.6.10
pika==1.1.0
pytz==2020.1
vine==1.3.0
zipp==3.1.0

Other Dependencies

N/A

Minimally Reproducible Test Case

app.py :

import celery
import time

app = celery.Celery("app", broker="amqp://guest:guest@localhost//")
app.conf.task_default_queue = "default"
app.conf.task_queue_max_priority = 100
app.conf.task_default_priority = 5
app.conf.worker_prefetch_multiplier = 1
app.conf.task_acks_late = True

@app.task
def dummy_low():
time.sleep(5)
print("dummy_low.")

@app.task
def dummy_high():
time.sleep(5)
print("dummy_high.")

def main():
print("Creating low prio tasks...")
for i in range(2000):
dummy_low.apply_async(priority=5)

print("Adding high prio task chain...")
tasks = dummy_high.si()
for i in range(100):
tasks = tasks | dummy_high.si()

tasks.apply_async(priority=8)

if __name__ == "__main__":
main()

Expected Behavior

High priority tasks are executed before the low priority tasks.

Actual Behavior

Only one (the first of the chain) high priority task is executed right away. The others are not priorized and thus not executed before the end of the low-priority tasks.

Please note that this doesn't happen with non-chained tasks or with grouped tasks. (with non-chained tasks or grouped tasks, priorities are respected.)

Issue 2:
Checklist

I have checked the issues list

for similar or identical feature requests.

I have checked the pull requests list

for existing proposed implementations of this feature.

I have checked the commit log

to find out if the if the same feature was already implemented in the

master branch.

I have included all related issues and possible duplicate issues

in this issue (If there are none, check this box anyway).

Related Issues and Possible Duplicates

Related Issues

None

Possible Duplicates

None

Brief Summary

I would like to be able to access arbitrary AMQP message properties (e.g. user-id) within my tasks.

Design

Architectural Considerations

None

Proposed Behavior

If the message received from the transport has a properties attribute, a reference to the value should be available in the app.task.Context instance available as self.request in a bound task. If there is no properties attribute, the new Context attribute may be set to None.

Proposed UI/UX

The new attribute in app.task.Context might be named properties.

Diagrams

N/A

Alternatives

Application-defined headers are already available to the task, but some functionality may be provided through broker interactions which cannot be replicated using application-defined headers (e.g. RabbitMQ's validated User-ID).

Another option would be to expose each of the remaining AMQP 0-9-1 message properties on the app.task.Context object similar to reply_to. This would have the disadvantage of introducing broker-specific logic.