The Fix
pip install celery==4.4.0rc5
Based on closed celery/celery issue #5470 · PR/commit linked
Production note: This usually shows up under retries/timeouts. Treat it as a side-effect risk until you can verify behavior with a canary + real traffic.
@@ -927,7 +927,7 @@ def update_state(self, task_id=None, state=None, meta=None, **kwargs):
if task_id is None:
task_id = self.request.id
- self.backend.store_result(task_id, meta, state, **kwargs)
+ self.backend.store_result(task_id, meta, state, request=self.request, **kwargs)
from collections import defaultdict
class MultiTenantBackend(BaseBackend):
def __init__(self, *args, **kwargs):
super(BaseBackend, self).__init__(*args, **kwargs)
self.store = defaultdict(dict)
def store_result(self, task_id, result, state, traceback=None, request=None, **kwargs):
tenant = request.get("_tenant")
self.store[tenant][task_id] = (result, state)
def ensure_chords_allowed(self):
pass
def as_uri(self, *args, **kwargs):
return None
def get_state(self, task_id):
return None
def get_status(self, task_id):
return None
def get_result(self, task_id):
return None
def get_traceback(self, task_id):
return None
def _get_task_meta_for(self, task_id):
return {}
def wait_for(self, *args, **kwargs):
pass
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.0rc5\nWhen NOT to use: Do not apply this fix if the task does not require the request object.\n\n
Why This Fix Works in Production
- Trigger: worker_1_e608e69813d9 | File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 385, in trace_task
- Mechanism: Task's `update_state` method calls `store_result` without passing the request object
- Why the fix works: Fixes the issue where `Task.update_state` calls `backend.store_result` without passing the request object, ensuring consistency in the task execution flow. (first fixed release: 4.4.0rc5).
- 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 2.7 in real deployments (not just unit tests).
- Task's `update_state` method calls `store_result` without passing the request object
- Surfaces as: Traceback (most recent call last):
Proof / Evidence
- GitHub issue: #5470
- Fix PR: https://github.com/celery/celery/pull/5474
- First fixed release: 4.4.0rc5
- 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.30
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“could you send a pr with the appropriate test?”
“Here is the PR https://github.com/celery/celery/pull/5474”
Failure Signature (Search String)
- worker_1_e608e69813d9 | File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 385, in trace_task
Error Message
Stack trace
Error Message
-------------
Traceback (most recent call last):
worker_1_e608e69813d9 | File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 385, in trace_task
worker_1_e608e69813d9 | R = retval = fun(*args, **kwargs)
worker_1_e608e69813d9 | File "/data/alaya/api/common/celery_app.py", line 113, in __call__
worker_1_e608e69813d9 | return super(RequestContextTask, self).__call__(*args, **kwargs)
worker_1_e608e69813d9 | File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 648, in __protected_call__
worker_1_e608e69813d9 | return self.run(*args, **kwargs)
worker_1_e608e69813d9 | File "/data/alaya/api/scheduleoptimization/alns/core/alns.py", line 70, in do_something
worker_1_e608e69813d9 | "some": "metadata",
worker_1_e608e69813d9 | File "/data/alaya/api/common/celery_app.py", line 140, in update_state
worker_1_e608e69813d9 | super(RequestContextTask, self).update_state(request=request, **args)
worker_1_e608e69813d9 | File "/usr/local/lib/python2.7/dist-packages/celery/app/task.py", line 930, in update_state
worker_1_e608e69813d9 | self.backend.store_result(task_id, meta, state, **kwargs)
worker_1_e608e69813d9 | File "/data/alaya/api/common/multi_tenant_backend.py", line 51, in store_result
worker_1_e608e69813d9 | tenant = request.get('_tenant')
worker_1_e608e69813d9 | AttributeError: 'NoneType' object has no attribute 'get'
Minimal Reproduction
from collections import defaultdict
class MultiTenantBackend(BaseBackend):
def __init__(self, *args, **kwargs):
super(BaseBackend, self).__init__(*args, **kwargs)
self.store = defaultdict(dict)
def store_result(self, task_id, result, state, traceback=None, request=None, **kwargs):
tenant = request.get("_tenant")
self.store[tenant][task_id] = (result, state)
def ensure_chords_allowed(self):
pass
def as_uri(self, *args, **kwargs):
return None
def get_state(self, task_id):
return None
def get_status(self, task_id):
return None
def get_result(self, task_id):
return None
def get_traceback(self, task_id):
return None
def _get_task_meta_for(self, task_id):
return {}
def wait_for(self, *args, **kwargs):
pass
Environment
- Python: 2.7
What Broke
Inconsistent task execution flow leading to potential task state issues.
Why It Broke
Task's `update_state` method calls `store_result` without passing the request object
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install celery==4.4.0rc5
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/celery/celery/pull/5474
First fixed release: 4.4.0rc5
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not apply this fix if the task does not require the request object.
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.0rc5 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.