The Fix
pip install celery==4.4.0
Based on closed celery/celery issue #4684 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -460,11 +460,24 @@ def _task_from_fun(self, fun, name=None, base=None, bind=False, **options):
task.bind(self) # connects task to this app
- autoretry_for = tuple(options.get('autoretry_for', ()))
- retry_kwargs = options.get('retry_kwargs', {})
- retry_backoff = int(options.get('retry_backoff', False))
from project.celery import app
class test_task(celery.Task):
autoretry_for = (Exception,)
retry_kwargs = {
'max_retries': 5,
'countdown': 10,
}
def run(self, *args, **kwargs):
raise Exception('test')
test_task = app.register_task(test_task())
test_task.delay()
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install celery==4.4.0\nWhen NOT to use: This fix should not be used if class-based tasks are not intended to have retry functionality.\n\nOption C — Workaround\na class similar to this could help you:\nWhen NOT to use: This fix should not be used if class-based tasks are not intended to have retry functionality.\n\n
Why This Fix Works in Production
- Trigger: autoretry_for = (Exception,)
- Mechanism: The autoretry_for attribute was not applied to class-based tasks due to implementation oversight
- Why the fix works: Allows class-based tasks to define retry attributes such as autoretry_for and retry_kwargs, addressing issue #4684. (first fixed release: 4.4.0).
- If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.
Why This Breaks in Prod
- Shows up under Python 3.7.4 in real deployments (not just unit tests).
- The autoretry_for attribute was not applied to class-based tasks due to implementation oversight
- Production symptom (often without a traceback): autoretry_for = (Exception,)
Proof / Evidence
- GitHub issue: #4684
- Fix PR: https://github.com/celery/celery/pull/5869
- First fixed release: 4.4.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.63
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“I think this would be a very neat feature (unless we want to actively discourage the use of class based tasks altogether) - if one…”
“Exactly the same issue for me. It looks like the autoretry_for attribute is only touched in _task_from_fun, which isn't used for a class based task.…”
“@CompadreP maybe as a little workaround a class similar to this could help you:”
“@amir-hadi Thanks for the idea. With small modifications I've got working retries with exponential backoff. Celery 4.3.0 Python 3.7.4 Further improvements: * Make it a…”
Failure Signature (Search String)
- autoretry_for = (Exception,)
- raise Exception('test')
Copy-friendly signature
Failure Signature
-----------------
autoretry_for = (Exception,)
raise Exception('test')
Error Message
Signature-only (no traceback captured)
Error Message
-------------
autoretry_for = (Exception,)
raise Exception('test')
Minimal Reproduction
from project.celery import app
class test_task(celery.Task):
autoretry_for = (Exception,)
retry_kwargs = {
'max_retries': 5,
'countdown': 10,
}
def run(self, *args, **kwargs):
raise Exception('test')
test_task = app.register_task(test_task())
test_task.delay()
Environment
- Python: 3.7.4
What Broke
Class-based tasks did not retry on failure, leading to task execution failures.
Why It Broke
The autoretry_for attribute was not applied to class-based tasks due to implementation oversight
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install celery==4.4.0
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Option C — Workaround Temporary workaround
a class similar to this could help you:
Use only if you cannot change versions today. Treat this as a stopgap and remove once upgraded.
Fix reference: https://github.com/celery/celery/pull/5869
First fixed release: 4.4.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if class-based tasks are not intended to have retry functionality.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
- Pin production dependencies and upgrade only with a reproducible test that hits the failing path.
Version Compatibility Table
| Version | Status |
|---|---|
| 4.4.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.