The Fix
pip install celery==5.2.7
Based on closed celery/celery issue #6525 · 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.
@@ -80,8 +80,10 @@ class NonTLS:
_state._tls = NonTLS()
- yield
- _state._tls = prev_tls
+ try:
Option A — Upgrade to fixed release\npip install celery==5.2.7\nWhen NOT to use: This fix should not be used if the application relies on the current_app fixture for its intended functionality.\n\n
Why This Fix Works in Production
- Trigger: setup_default_app doesn't use app argument (or the current_app fixture does nothing)
- Mechanism: The app argument in setup_default_app is not assigned to the current state globals, causing it to be ineffective
- Why the fix works: Makes the `start_worker` and `setup_default_app` functions reusable outside of pytest by ensuring proper cleanup using a try-finally pattern. (first fixed release: 5.2.7).
- 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
- The app argument in setup_default_app is not assigned to the current state globals, causing it to be ineffective
- Production symptom (often without a traceback): setup_default_app doesn't use app argument (or the current_app fixture does nothing)
Proof / Evidence
- GitHub issue: #6525
- Fix PR: https://github.com/celery/celery/pull/7503
- First fixed release: 5.2.7
- 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.82
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“might be fixed by https://github.com/celery/celery/pull/7503”
Failure Signature (Search String)
- setup_default_app doesn't use app argument (or the current_app fixture does nothing)
- * [x] I have included all related issues and possible duplicate issues
Copy-friendly signature
Failure Signature
-----------------
setup_default_app doesn't use app argument (or the current_app fixture does nothing)
* [x] I have included all related issues and possible duplicate issues
Error Message
Signature-only (no traceback captured)
Error Message
-------------
setup_default_app doesn't use app argument (or the current_app fixture does nothing)
* [x] I have included all related issues and possible duplicate issues
What Broke
The current_app fixture does not reflect the intended test app, leading to incorrect application behavior.
Why It Broke
The app argument in setup_default_app is not assigned to the current state globals, causing it to be ineffective
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install celery==5.2.7
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/7503
First fixed release: 5.2.7
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if the application relies on the current_app fixture for its intended functionality.
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 |
|---|---|
| 5.2.7 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.