The Fix
pip install celery==5.6.2
Based on closed celery/celery issue #10042 · 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.
@@ -129,10 +129,10 @@ def _now(self) -> datetime:
class DjangoWorkerFixup:
_db_recycles = 0
+ worker = None # Set via on_worker_init callback to avoid recursive WorkController instantiation
- def __init__(self, app: "Celery", worker: Optional["WorkController"] = None) -> None:
File "/usr/local/lib/python3.12/site-packages/celery/fixups/django.py", line 220, in _close_database
is_prefork = "prefork" in self.worker.pool_cls.__module__
│ │ └ 'prefork'
│ └ <Worker: celery@75efc8aa2596 (INIT)>
└ <celery.fixups.django.DjangoWorkerFixup object at 0x7f77b5998f20>
AttributeError: 'str' object has no attribute '__module__'. Did you mean: '__mod__'?
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==5.6.2\nWhen NOT to use: This fix should not be used if the application does not utilize Django with Celery.\n\n
Why This Fix Works in Production
- Trigger: is_prefork = "prefork" in self.worker.pool_cls.__module__
- Mechanism: Fixes a critical recursion bug in DjangoWorkerFixup.__init__ that causes infinite recursion during worker instantiation when using Django with Celery, addressing the AttributeError issue.
- Why the fix works: Fixes a critical recursion bug in DjangoWorkerFixup.__init__ that causes infinite recursion during worker instantiation when using Django with Celery, addressing the AttributeError issue. (first fixed release: 5.6.2).
- 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.12 in real deployments (not just unit tests).
- Surfaces as: File "/usr/local/lib/python3.12/site-packages/celery/fixups/django.py", line 220, in _close_database
Proof / Evidence
- GitHub issue: #10042
- Fix PR: https://github.com/celery/celery/pull/10045
- First fixed release: 5.6.2
- Reproduced locally: No (not executed)
- Last verified: 2026-02-08
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.38
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“I am using a celery container as part of django-cookiecutter created project and the error in this issue is causing my containers to fail, and…”
“> I can't get my production stack up, probably because of this error, but currently it might be something else, I am still checking. Yes,…”
“we got this prospective fix https://github.com/celery/celery/pull/10045 can you guys try this please?”
Failure Signature (Search String)
- is_prefork = "prefork" in self.worker.pool_cls.__module__
Error Message
Stack trace
Error Message
-------------
File "/usr/local/lib/python3.12/site-packages/celery/fixups/django.py", line 220, in _close_database
is_prefork = "prefork" in self.worker.pool_cls.__module__
│ │ └ 'prefork'
│ └ <Worker: celery@75efc8aa2596 (INIT)>
└ <celery.fixups.django.DjangoWorkerFixup object at 0x7f77b5998f20>
AttributeError: 'str' object has no attribute '__module__'. Did you mean: '__mod__'?
Stack trace
Error Message
-------------
File "/usr/local/lib/python3.12/site-packages/celery/fixups/django.py", line 116, in on_worker_init
self.worker_fixup.install()
File "/usr/local/lib/python3.12/site-packages/celery/fixups/django.py", line 161, in install
self.close_database()
File "/usr/local/lib/python3.12/site-packages/celery/fixups/django.py", line 207, in close_database
return self._close_database()
File "/usr/local/lib/python3.12/site-packages/celery/fixups/django.py", line 220, in _close_database
is_prefork = "prefork" in self.worker.pool_cls.__module__
AttributeError: 'str' object has no attribute '__module__'
Minimal Reproduction
File "/usr/local/lib/python3.12/site-packages/celery/fixups/django.py", line 220, in _close_database
is_prefork = "prefork" in self.worker.pool_cls.__module__
│ │ └ 'prefork'
│ └ <Worker: celery@75efc8aa2596 (INIT)>
└ <celery.fixups.django.DjangoWorkerFixup object at 0x7f77b5998f20>
AttributeError: 'str' object has no attribute '__module__'. Did you mean: '__mod__'?
Environment
- Python: 3.12
What Broke
An AttributeError is raised, causing Flower to fail and preventing the production stack from starting.
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install celery==5.6.2
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/10045
First fixed release: 5.6.2
Last verified: 2026-02-08. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if the application does not utilize Django with Celery.
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 |
|---|---|
| 5.6.2 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.