Repository navigation
Closed
Description
Chords are not working with exchanges of type headers because the method fallback_chord_unlock doesn't forward headers to the unlock tasks.
To reproduce:
import celery
from celery import Celery, chord
from celery.canvas import Signature
from kombu import Exchange, Queue
app = Celery(
'example',
broker='amqp://guest:guest@rabbitmq//',
backend='db+postgresql://celery:celery@postgres/celery',
)
app.conf['CELERY_QUEUES'] = (
Queue('my_queue',
exchange=Exchange('my_exchange', type='headers'),
binding_arguments={'my_header': 'my_value'}),
)
app.conf['CELERY_CREATE_MISSING_QUEUES'] = False
app.conf.CELERY_DEFAULT_QUEUE = 'my_queue'
@app.task
def add(x, y):
print('add %s and %s' % (x, y))
return x + y
@app.task
def total(values):
print('sum called with', values)
return True
def main():
sig = Signature(
'example.add',
args=[1, 1],
headers={
'my_header': 'my_value',
}
)
sig2 = Signature(
'example.add',
args=[2, 2],
headers={
'my_header': 'my_value',
}
)
sig_total = Signature(
'example.total',
headers={
'my_header': 'my_value',
}
)
chord([sig, sig2])(sig_total)
if __name__ == '__main__':
main()A naive fix is to add headers=body.options.get('headers') to self.app.tasks['celery.chord_unlock'].apply_async() in fallback_chord_unlock().
From my understanding, it should be broken too for direct exchanges because the routing_key is not forwarded too.
This is broken since at least 3.1.26post2.
Reacted by Fabien Malfoy, Pierre Muller and Louis Bouchard
Activity
open-collective-bot commentedon Mar 23, 2021
Hey @brmzkw 👋,
Thank you for opening an issue. We will get back to you as soon as we can.
Also, check out our Open Collective and consider backing us - every little helps!
We also offer priority support for our sponsors.
If you require immediate assistance please consider sponsoring us.
brmzkw commentedon Mar 23, 2021
As you requested on IRC, ping @xirdneh