Jump to solution
Verify

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.

Jump to Verify Open PR/Commit
@@ -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:
repro.py
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__'?
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
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).
Production impact:
  • 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…”
@millerthegorilla · 2026-01-02 · source
“> 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,…”
@msamoylov · 2026-01-02 · source
“we got this prospective fix https://github.com/celery/celery/pull/10045 can you guys try this please?”
@auvipy · 2026-01-03 · source

Failure Signature (Search String)

  • is_prefork = "prefork" in self.worker.pool_cls.__module__

Error Message

Stack trace
error.txt
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.txt
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

repro.py
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

When NOT to use: This fix should not be used if the application does not utilize Django with Celery.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix should not be used if the application does not utilize Django with Celery.

Verify Fix

verify
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

VersionStatus
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.