Repository navigation
Closed
Closed
Copy link
Milestone
Description
When nesting three-level depth chords (the construct is shown below), the body of the "middle chord" (the B task body) does not seem to be sent to the worker.
chord([
chord([
chord([
task
], body=A)
], body=B)
], body=D)
I tested this kind of construct against Celery 3.1.23 and it worked fine.
celery report output
➜ celery -A tasks report
software -> celery:4.0.0rc3 (0today8) kombu:4.0.0rc3 py:3.5.1
billiard:3.5.0.0rc2 py-amqp:2.0.3
platform -> system:Darwin arch:64bit imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:amqp results:redis://192.168.99.100:6379/0
CELERY_RESULT_BACKEND: 'redis://192.168.99.100:6379/0'
BROKER_URL: 'amqp://guest:********@192.168.99.100:5672//'
CELERY_TIMEZONE: 'Europe/Paris'
CELERYD_PREFETCH_MULTIPLIER: 1
code sample
@app.task
def simple_task():
return 'simple_task'
@app.task
def simple_body(args):
return 'simple_body'
@app.task
def lower_body(args):
return 'lower_body'
@app.task
def higher_body(args):
return 'higher_body'
def test_chords():
c = chord(
group([
chord(
group([
chord(
group([simple_task.s()]),
body=simple_body.s()
)
]),
body=lower_body.s()
)
]),
body=higher_body.s()
)
print(c)
c.delay()code execution
- Calling
test_chordsfunction - the printedchordlooks fine (I re-indented it manually for clarity's sake)
>>> from tasks import test_chords
>>> test_chords()
tasks.higher_body([
tasks.lower_body([
tasks.simple_body([
tasks.simple_task()
])
])
])
- Worker output - the
lower_bodytask was not received by the worker
[2016-07-19 12:00:24,421: INFO/MainProcess] Received task: tasks.simple_task[853a3639-1b01-4185-8eac-561f567e3cd1]
[2016-07-19 12:00:26,107: INFO/PoolWorker-8] Task tasks.simple_task[853a3639-1b01-4185-8eac-561f567e3cd1] succeeded in 0.03156297900022764s: 'simple_task'
[2016-07-19 12:00:26,108: INFO/MainProcess] Received task: tasks.simple_body[8bef991a-50b2-4daf-858a-4c81005bb6e1]
[2016-07-19 12:00:26,142: INFO/PoolWorker-3] Task tasks.simple_body[8bef991a-50b2-4daf-858a-4c81005bb6e1] succeeded in 0.0327701000005618s: 'simple_body'
[2016-07-19 12:00:26,143: INFO/MainProcess] Received task: tasks.higher_body[31cf3a3d-de1a-4ebb-ab55-ae46910d12f1]
[2016-07-19 12:00:26,153: INFO/PoolWorker-4] Task tasks.higher_body[31cf3a3d-de1a-4ebb-ab55-ae46910d12f1] succeeded in 0.007895638998888899s: 'higher_body'
Activity
bruno-rino commentedon Aug 9, 2016
This seems to be a rabbitmq specific bug. Your sample code works fine using redis. Related to #3330
ask commentedon Sep 8, 2016
Could you try this now with the most recent master?
aauroy commentedon Sep 9, 2016
As of commit 8e8b428, the bug is still present. Furthermore, I could also reproduce the bug when using redis as a broker, which let me think that it is not a rabbitmq specific bug.
using redis as a broker - the
lower_bodybody task is still not sent/receivedcelery report output - redis as a broker
celery report output - rabbitmq as a broker
bruno-rino commentedon Sep 9, 2016
Well, I'm not sure what I tested before.
But from my testing today, using the latest master, it seems the problem is that when using explicit chords, the choice of result_backend matters. I didn't get either redis or rpc to work.
The following changes to your setup make it work:
Now, for setups that don't work:
ask commentedon Nov 1, 2016
Something like this works well for me:
Note: I changed the tasks to take a integer argument, just so I could track what happens.
These are three nested chords, but the major difference is that the groups are actual groups, since they contain more than one task.
In your example the groups are pointless, you're defining chords that could just be a simple chain:
Another version that seems to work is:
I'm guessing this is due to how the
|(OR) operator is much smarter than using thechainclass, since the OR operator are able to optimize away some pointless constructs (OR operator is allowed to return a different type, while creating achainexplicitly cannot return a different type).We already unroll groups ORed together:
We should probably also unroll chords where the group only has one member:
Canvas: chain(X, Y, Z) is now the same as X | Y | Z (related to discu…
Fix length-1 and nested chords (#4393 #4055 #3885 #3597 #3574 #3323) (#…