[mod_python] mod_python session trouble

Wouter van Marle wouter at squirrel-systems.com
Tue May 10 02:53:21 EDT 2005

On Tue, 2005-05-10 at 02:01 -0400, Jim Gallacher wrote:
> This looks like a problem with session locking, which is the default 
> when creating a session. Are you creating more than one session object 
> in a request? If so you'll end up with a deadlock. For example the 
> following code will deadlock as it is really just accessing the same 
> session data:
> sess1 = Session.Session(req)
> sess2 - Session.Session(req)

This is really close to what I am doing. I've to shorten my code a lot
to get it posted here, but basically this happens:

def home(req):
    sess = Session.Session(req)
    if sess.is_new():
        # get settings from cookies (using Cookie)
    # page built up, using sess["language"] for the language setting.
    return apache.OK

def english(req)
    sess = Session.Session(req)
    sess["language"] = "en"
    home(req) # to redraw the main page

And same for other languages as well.
The page uses a little PSP to easily set some variables, no code in the
pages. It appears to hang on the Session.Session(req) call in the
english routine.
The english routine is called through a hyperlink off the main page (a
href main.py/english).


More information about the Mod_python mailing list