[mod_python] Session "deadlock" feature / bug ?

mike bayer mike_mp at zzzcomputing.com
Wed Sep 8 21:31:27 EDT 2004


hi -

this is a slightly tricky one to demonstrate.  Running apache 2.0 with the
worker MPM on linux, it appears that a page that requests a Session, and
then takes a really long time to finish, blocks certain other
session-enabled pages from completing, regardless of which session ID they
have.  though not every page, just maybe ones in the same child process ? 
not totally sure.

I am assuming this behavior is due to the global locking mechanism used
within Session (to which I cant readily find documentation).   I have a
feeling this is "expected" behavior as opposed to a bug....though it sort
of sucks if thats the case.  I suppose I am looking for a description of
why the below example does what it does.

first, run apache with the worker MPM with a pretty small process/thread
size, say 5 ThreadsPerChild and 2 StartServers.

then, mptest.py, configured just like mptest.py in the mod python
documentation:

from mod_python import apache, util, Session
from time import sleep

def handler(req):
        req.content_type = 'text/html'

        session = Session.Session(req)

        fields = util.FieldStorage(req)
        if fields.has_key('pause'):
                req.write("hi, this is a very slow page\n")
                sleep(5)
                req.write("really, a very slow page\n")
                sleep(5)
                req.write("ok\n")

        else:

                req.write("""
hello world ! reloading in 100ms

<script>setTimeout('window.location.href="mptest.py"', 100)</script>

""")
        return apache.OK


Then, set your browser to call the fast version over and over again:

http://myserver.com/mptest.py

then to watch it hang due to a totally unrelated access by someone else,
go to a shell window somewhere and type:

wget --output-document=- http://myserver.com/mptest.py?pause=1

to get the slow version.  at least on my server, the fast-reloading page
will hit a certain process/thread that will just hang, and there it will
stay until your slow command-line one completes.

i am gathering this is either totally new news, or utterly obvious to
everyone but me.  comments ?




More information about the Mod_python mailing list