mod_wsgi force reload modules

Ian picture Ian · Apr 20, 2009 · Viewed 9.4k times · Source

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

Answer

Graham Dumpleton picture Graham Dumpleton · Jun 24, 2009

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.