Once every few hundred thousand requests I see one of these:
ImportError at /
cannot import name 'Config' from partially initialized module 'constance.base' (most likely due to a circular import) (/usr/local/lib/python3.9/site-packages/constance/base.py)
I cannot identify any rhyme or reason. It doesn't correspond with accessing constance
admin, just randomly occurs. My best guess is it's something to do with the LazyObject
in constance's __init__.py
, and maybe random race-conditions in restarting expired gunicorn
workers or something?!
I'm using:
- Python 3.9.2
- Django 3.2
django-constance = {extras = ["database"],version = "==2.8.*"}
"constance"
and"constance.backends.database"
inINSTALLED_APPS
(at top)CONSTANCE_BACKEND = "constance.backends.database.DatabaseBackend"
"constance.context_processors.config"
inTEMPLATES[0]["OPTIONS"]["context_processors"]
All my code does is from constance import config
and access config
attributes in the standard way in python code and Django templates.
For what it's worth, we've been using django-constance
on this site for years, but never saw this error until we upgraded to 2.8.0
(from 2.6.0
). We were using Django 3.1 when it first appeared, but has also occurred since upgrading to 3.2.
I cannot find any similar error reports on https://github.com/jazzband/django-constance/
Any ideas what could be causing this and how to resolve it?
from Why am I very-occasionally getting an ImportError using django-constance?
No comments:
Post a Comment