[mod_python] For what session locking is? Do i need it while using MySQL?

Jim Gallacher jpg at jgassociates.ca
Thu Aug 10 09:40:45 EDT 2006

Norman Tindall wrote:
> Hello Graham,
> Thursday, August 10, 2006, 2:07:06 PM, you wrote:
> GD> There has been discussion on MySQL implementation of Session
> GD> functionality
> GD> on developers list recently. Go to:
> GD>    http://mail-archives.apache.org/mod_mbox/httpd-python-dev/
> GD> 200608.mbox/thread
> GD> and read the posts about MySQLSession.
> GD> This probably will not answer all your questions, but then what you
> GD> are actually
> GD> wanting to know isn't particularly clear.
> GD> Graham
>    Nah, that module in mail-archives.apache.org won`t suit my needs,
>    besides i dont need standard BaseSession behavior ( dict like
>    structure and also to create new sess if none).
>    Explain me please why session has to be locked?
>    What Session lock is?
>    The main thing i can`t understand by now.. - is session object
>    shared between thread?

Hopefully my previous reply made things a little clearer.

If you want to create your own session handling from scratch but don't
understand session locking and haven't done any programming using
threads or multiple processes, all I can say is....  good luck.

I can just about guarantee you'll get it wrong, just because *everybody*
gets it wrong the first time (and probably many times after that as
well). It seems simple but the problems are subtle.

Problems with race conditions are tricky because they are seemingly
random. You might see something odd once in 1000 requests or maybe once
in 100000, or maybe never. All you'll know is that at some point in time
your data will be corrupted and you'll be tearing your hair out trying
to figure out why.

Race conditions are bad, deadlocks are worse but at least easy to
diagnose, since in the worst case Apache will stop responding.


More information about the Mod_python mailing list