Code change monitoring failed with Django 1.7 on mod-wsgi

This is the problem I encountered on all of my sites running Django 1.7 in mod_wsgi. The problem is that if, developing locally, I introduce a fatal error into the code base and then fix it, monitoring the script code does not detect a correction.

I use the Graham Dumpleton monitor.py script to detect changes in the codebase when I develop locally (I use apache, not the Django development server).

It always worked in Django <= 1.6, but in Django 1.7 I get the following error:

File "/home/me/.virtualenvs/myvirtualenv/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application django.setup() File "/home/me/virtualenvs/myvirtualenv/lib/python2.7/site-packages/django/__init__.py", line 21, in setup apps.populate(settings.INSTALLED_APPS) File "/home/me/.virtualenvs/myvirtualenv/lib/python2.7/site-packages/django/apps/registry.py", line 78, in populate raise RuntimeError("populate() isn't reentrant") RuntimeError: populate() isn't reentrant 

It is annoying that if I fix the error, monitor.py will not detect the change, so I must either restart apache or touch another file that has already been downloaded (for example, a settings file).

I think this is because "the reboot code only tracks imported files (aka sys.modules)" ( source ). Since the wrong file was not successfully imported, monitor.py does not know to restart the process.

+7
django apache mod-wsgi
Dec 01 '14 at 16:26
source share
1 answer

I'm not sure what your deployment process is and your production operating system, but in the Linux / Ubuntu world there is an OS command called pyclean. During my Django / Python deployment scripts (usually through the fabric) I issue the pyclean command. at the root of the project. This script recursively deletes all .pyc files starting from the current folder. Hope this helps.

0
Jul 11 '17 at 17:44
source share



All Articles