More mod_wsgi weirdness: process restarts on redirect

Ron Garret rNOSPAMon at flownet.com
Thu Jan 29 18:43:49 EST 2009


In article <rNOSPAMon-A73662.15010729012009 at news.gha.chartermi.net>,
 Ron Garret <rNOSPAMon at flownet.com> wrote:

> I'm running mod_wsgi under apache (on Debian etch so it's a somewhat out 
> of date version, though I doubt that has anything to do with this issue).
> 
> I have a little test page that displays the process ID under which my 
> app is running, and some global state, so I can tell when the wsgi app 
> gets reloaded.  This mostly only happens when I restart apache, but it 
> also seems to happen when my WSGI app does an HTTP 302 redirect.  (I'm 
> actually using Yaro and calling req.redirect, but that only does a 
> straightforward HTTP 302 redirect as far as I can tell.)  It not only 
> resets the global state, but changes process ID, so it seems to be doing 
> a complete restart of mod_wsgi, which seems a little excessive.
> 
> My question is: is this supposed to be happening?  Or is this an 
> indication that something is wrong, and if so, what?
> 
> Thanks,
> rg

Here's a standalone WSGI app demonstrating the phenomenon:

def redirect_test(env, start):
  if env['PATH_INFO']:
    start('302 Found', [('Location', '/')])
    return ['Redirecting']
  else:
    start('200 OK', [('Content-type', 'text/plain')])
    return ['PID', str(os.getpid())]
  pass

application = redirect_test


Fire this up under mod_wsgi and observe that the process ID stays the 
same when you reload the app.  Now add a path component to trigger the 
redirect and observe that process ID changes.

rg



More information about the Python-list mailing list