[mod_python] ValueError: Failed to acquire global mutex lock

Gregory (Grisha) Trubetskoy grisha at modpython.org
Sun Nov 23 23:25:29 EST 2003



On Mon, 24 Nov 2003, Julian Ciccale wrote:

> Kind of. What I do is the followoing
>
> try:
>     from mod_python.Session import Session as DefaultSessionCall
> except:
>     def DefaultSessionCall( r ):
>        return None
>
> , this is a peice of code I use to make configurable the Session class
> the user wants to use.

This is fine, but make sure that after you do:

   session = DefaultSessionCall(r)

that the session variable is not referenced by anything after the request
is done. Or you can explicitely unlock it:

   session.unlock()

> I also then try to call a setter method on a user's class to pass the
> session he works on. How should I use the session? The locking mechanism
> is needed for read/write or just write?

You don't need to worry about locking for read and write, that locking is
taken care of automtically. You need session locking to make sure that no
two HTTP requests for the same session execute at the same time.

> I think I may write a session wrapper class to lock unlock on user call
> to get/set properties..

Your wrapper can avoid session locking altogether by instantiating it as
such:

session = Session(req, lock=0)

Grisha


More information about the Mod_python mailing list