Checklist
Mandatory Debugging Information
Optional Debugging Information
Related Issues and Possible Duplicates
Related Issues
Possible Duplicates
Environment & Settings
Celery version: 5.3.1 (emerald-rush)
celery report Output:
software -> celery:5.3.1 (emerald-rush) kombu:5.3.1 py:3.10.7
billiard:4.1.0 redis:5.0.0
platform -> system:Darwin arch:64bit
kernel version:22.6.0 imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:redis results:redis://localhost/
broker_url: 'redis://localhost:6379//'
result_backend: 'redis://localhost/'
deprecated_settings: None
task_allow_error_cb_on_chord_header: True
Steps to Reproduce
Required Dependencies
- Minimal Python Version: 3.10.x
- Minimal Celery Version: 5.3.1
- Minimal Kombu Version: N/A
- Minimal Broker Version: N/A
- Minimal Result Backend Version: N/A
- Minimal OS and/or Kernel Version: N/A (we've reproduced with our own deployment on Linux, and locally on macOS)
- Minimal Broker Client Version: N/A
- Minimal Result Backend Client Version: N/A
Python Packages
pip freeze Output:
amqp==5.1.1
async-timeout==4.0.3
billiard==4.1.0
celery @ git+https://github.com/celery/celery.git@8ae0b229596cc8aeea4fb71020d9358a59338e08
click==8.1.7
click-didyoumean==0.3.0
click-plugins==1.1.1
click-repl==0.3.0
kombu==5.3.1
prompt-toolkit==3.0.39
python-dateutil==2.8.2
redis==5.0.0
six==1.16.0
tzdata==2023.3
vine==5.0.0
wcwidth==0.2.6
Other Dependencies
Details
N/A
Minimally Reproducible Test Case
Details
from celery import Celery, chain, group, chord
app = Celery('tasks', broker='redis://localhost/', backend='redis://localhost/')
app.conf.task_allow_error_cb_on_chord_header = True
@app.task
def fake_work_unit(x):
raise Exception
@app.task
def nothing_work_unit():
return "hi"
@app.task
def fake_error_handler(*args):
print("oops")
def test():
f = app.signature(
"test_celery.nothing_work_unit",
immutable=True,
)
f2 = app.signature(
"test_celery.fake_error_handler",
)
# This formulation works correctly...
# chain(
# f.on_error(f2),
# group(
# app.signature(
# "test_celery.fake_work_unit",
# args=(1,),
# immutable=True,
# ),
# app.signature(
# "test_celery.fake_work_unit",
# args=(2,),
# immutable=True,
# ),
# ).on_error(f2),
# f.on_error(f2),
# ).apply_async()
# ...but not this one.
chain(
f,
group(
app.signature(
"test_celery.fake_work_unit",
args=(1,),
immutable=True,
),
app.signature(
"test_celery.fake_work_unit",
args=(2,),
immutable=True,
),
),
f,
).on_error(f2).apply_async()
Run celery -A test_celery worker and then in a different shell:
from test_celery import test
test()
Then comment out the second formulation and uncomment the first. Notice that it works as intended.
This test case also works if you disable task_allow_error_cb_on_chord_header, or remove the on_error/link_error call, but either will result in the error handler being invoked.
Expected Behavior
Either formulation described should work. The second formulation should not be throwing AttributeError.
The intended result is:
test_celery.nothing_work_unit succeeds.
- One of the
test_celery.fake_work_unit tasks runs and raises an exception, causing fake_error_handler to be called.
Actual Behavior
When trying to run the second formulation, I get an AttributeError and no task is ever run:
>>> from test_celery import test
>>> test()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/asteinborn/Ramp/misc/celery-test/test_celery.py", line 68, in test
).on_error(f2).apply_async()
File "/Users/asteinborn/Ramp/misc/celery-test/venv/lib/python3.10/site-packages/celery/canvas.py", line 1035, in apply_async
return self.run(args, kwargs, app=app, **(
File "/Users/asteinborn/Ramp/misc/celery-test/venv/lib/python3.10/site-packages/celery/canvas.py", line 1060, in run
tasks, results_from_prepare = self.prepare_steps(
File "/Users/asteinborn/Ramp/misc/celery-test/venv/lib/python3.10/site-packages/celery/canvas.py", line 1246, in prepare_steps
task.link_error(errback)
File "/Users/asteinborn/Ramp/misc/celery-test/venv/lib/python3.10/site-packages/celery/canvas.py", line 2276, in link_error
task.link_error(errback.clone(immutable=True))
AttributeError: 'str' object has no attribute 'link_error'
Checklist
mainbranch of Celery.contribution guide
on reporting bugs.
for similar or identical bug reports.
for existing proposed fixes.
to find out if the bug was already fixed in the main branch.
in this issue (If there are none, check this box anyway).
Mandatory Debugging Information
celery -A proj reportin the issue.(if you are not able to do this, then at least specify the Celery
version affected).
mainbranch of Celery.pip freezein the issue.to reproduce this bug.
Optional Debugging Information
and/or implementation.
result backend.
broker and/or result backend.
ETA/Countdown & rate limits disabled.
and/or upgrading Celery and its dependencies.
Related Issues and Possible Duplicates
Related Issues
Possible Duplicates
Environment & Settings
Celery version: 5.3.1 (emerald-rush)
celery reportOutput:Steps to Reproduce
Required Dependencies
Python Packages
pip freezeOutput:Other Dependencies
Details
N/A
Minimally Reproducible Test Case
Details
Run
celery -A test_celery workerand then in a different shell:Then comment out the second formulation and uncomment the first. Notice that it works as intended.
This test case also works if you disable
task_allow_error_cb_on_chord_header, or remove theon_error/link_errorcall, but either will result in the error handler being invoked.Expected Behavior
Either formulation described should work. The second formulation should not be throwing
AttributeError.The intended result is:
test_celery.nothing_work_unitsucceeds.test_celery.fake_work_unittasks runs and raises an exception, causingfake_error_handlerto be called.Actual Behavior
When trying to run the second formulation, I get an
AttributeErrorand no task is ever run: