views:

231

answers:

3

Is there a way to have mod_wsgi reload all modules (maybe in a particular directory) on each load?

While working on the code, it's very annoying to restart apache every time something is changed. The only option I've found so far is to put modname = reload(modname) below every import.. but that's also really annoying since it means I'm going to have to go through and remove them all at a later date..

+1  A: 

The mod_wsgi documentation on code reloading is your best bet for an answer.

Ignacio Vazquez-Abrams
I was reading that.. wasn't that helpful though :(
Ian
Ian, is this because you are on Windows or using mod_wsgi in embedded mode? Because otherwise that page has some code for automatic restart and it works perfectly.
Van Gale
Nope, this is on linux.The automatic reloading only applies to the script being accessed, not the modules that the script then calls.
Ian
A: 

I recently hacked something together which checks the modification time of the file containing the modules I am looking at, and reloads when that time changes.

Mike Boers
+4  A: 

The link:

http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode

should be emphasised. It also should be emphaised that on UNIX systems daemon mode of mod_wsgi must be used and you must implement the code monitor described in the documentation. The whole process reloading option will not work for embedded mode of mod_wsgi on UNIX systems. Even though on Windows systems the only option is embedded mode, it is possible through a bit of trickery to do the same thing by triggering an internal restart of Apache from the code monitoring script. This is also described in the documentation.

Graham Dumpleton