[mod_python] Session unable to acquire mutex lock?

Gregory (Grisha) Trubetskoy grisha at modpython.org
Sun Dec 28 13:28:12 EST 2003


If you restart the server, and try this code, does the error happen on the
first hit, or only starting with the second and after waiting for a while?

If if it's the former, then there probably is some problem with locking in
general (are there any warning messages on server startup?). If it's
latter, then the session does not get unlocked properly. It should get
unlocked when the sess object goes out of scope (and looking at your code
it should), but perhpas try unlocking it manually (sess.unlock()) and see
if this fixes the problem.

Grisha

On Sat, 27 Dec 2003, Russell Lear wrote:

> Hi,
>
> I'm a newbie to mod_python so forgive me if this is a terribly obvious
> question (I've looked through the archives without much success).
>
> I'm trying to use sessions.  Right now I have a slightly modified version
> of mptest.py as follows (it doesn't make sense, but it does show my
> problem):
>
>     from mod_python import apache, Session
>     import sys
>
>     def handler(req):
>         req.content_type = 'text/plain'
>         req.write("Creating...\n")
>         sess = Session.Session(req)
>         req.write("Hello World!")
>         return apache.OK
>
> When I run it, I see:
>
>      Mod_python error: "PythonHandler mptest"
>
>      Traceback (most recent call last):
>
>        File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 338, in HandlerDispatch
>          result = object(req)
>
>        File "/srv/www/htdocs/test/mptest.py", line 7, in handler
>          sess = Session.Session(req)
>
>        File "/usr/lib/python2.3/site-packages/mod_python/Session.py", line 411, in Session
>          timeout=timeout)
>
>        File "/usr/lib/python2.3/site-packages/mod_python/Session.py", line 316, in __init__
>          secret=secret, timeout=timeout)
>
>        File "/usr/lib/python2.3/site-packages/mod_python/Session.py", line 170, in __init__
>          self.lock()                 # lock new sid
>
>        File "/usr/lib/python2.3/site-packages/mod_python/Session.py", line 241, in lock
>          _apache._global_lock(self._req.server, self._sid)
>
>      ValueError: Failed to acquire global mutex lock
>
>
> What am I doing wrong here?!
>
> Thanks for any suggestions,
> Russell.
>
> PS:
>
> I'm running on SuSE 9.0 Linux.
>
> Python reports version "Python 2.3+ (#1, Sep 23 2003, 23:07:16)".
>
> >From the Apache error page:
>     Apache/2.0.48 (Linux/SuSE),
>     mod_python/3.1.2b
>     Python/2.3+.
>
> The only glitch I had in building mod_python was that I needed to specify
>     ./configure --with-apxs=/usr/sbin/apxs2
>
> rather than just refering to apxs.
>
> My apache configuration is (from the tutorial):
> <Directory /srv/www/htdocs/test>
>   AddHandler python-program .py
>   PythonHandler mptest
>   PythonDebug On
> </Directory>
>
>
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>


More information about the Mod_python mailing list