Sloooooowwwww WSGI restart

Graham Dumpleton Graham.Dumpleton at gmail.com
Thu Jan 29 02:16:19 CET 2009


On Jan 29, 8:44 am, Aleksandar Radulovic <a... at a13x.net> wrote:
> Hi there,
>
> On Wed, Jan 28, 2009 at 9:35 PM, Ron Garret <rNOSPA... at flownet.com> wrote:
> > I'm running a WSGI app under apache/mod_wsgiand I've noticed that
>
> Off the bat, there's no reason to run an app under apache/mod_wsgi
> while developing it,
> ie. if u use Pylons or TurboGears, there's an easier way to serve the
> app (using paster
> or cherrypy).
>
> Secondly, why are you restarting apache after code changes? In normal
> circumstances,
> you shouldn't have to do that.

Sorry, you are wrong to assume that an Apache restart is not be
required.

If you are using mod_wsgi embedded mode, or mod_python, then a code
change will always require a full restart of Apache.

If you are using mod_wsgi daemon mode, you need to at least touch the
WSGI script file for an automatic restart of that specific application
to occur. Changes to arbitrary Python code files are not detected.

If using mod_wsgi daemon mode, you can also set up a separate
background thread to monitor for arbitrary code changes as described
for Django in:

  http://blog.dscpl.com.au/2008/12/using-modwsgi-when-developing-django.html

That page references original documentation on mod_wsgi wiki for bulk
of information.

Thus, the conjecture that Apache/mod_wsgi cannot be used and that
CherryPy WSGI server or Paster server must be used when developing a
Python web application is false. If using mod_wsgi then daemon mode
would of course be preferred though, with touching the WSGI script
file being safest option to ensure updates across multiple files
picked up at same time, but if you really want completely automated
restarts, use the recipe in mod_wsgi documentation.

Graham



More information about the Python-list mailing list