[mod_python] Sessions performance and some numbers

Nicolas Lehuen nicolas.lehuen at gmail.com
Thu Apr 7 17:26:01 EDT 2005


On Apr 7, 2005 10:59 PM, Nicolas Lehuen <nicolas.lehuen at gmail.com> wrote:
> On Apr 7, 2005 9:39 PM, Jim Gallacher <jg.lists at sympatico.ca> wrote:
> > Nicolas Lehuen wrote:
> > > Hi,
> > >
> > > Your code seems perfect to me. We could indeed add an extra hash to
> > > the directory name so that all sessions do not end in the same
> > > directory ; but I guess this is not needed on modern FS like ReiserFS
> > > or WinFS.
> > >
> > > Also, the unlink call in do_delete needs an "os." to be correct...
> > >
> > > If everybody is OK I could integrate your class into the Session.py
> > > module, so that it becomes a standard session implementation in the
> > > next release.
> >
> > Shouldn't a lock be aquired and released before reading and writing the
> > session to a file?
> 
> Yeah, of course, though we could rely on the native filesystem locking
> capabilities.
> 
> Regards,
> Nicolas

[switching to python-dev]

Woops, sorry, I did not see that the locking problem is handled in
BaseSession. From what I read in the source code, the locking is
handled with the granularity of one lock per session, am I right ? So,
as we have one file per session, we can reuse the same locking
mechanisms in do_load, do_save and do_delete. Does this sound OK to
you ?

I've seen a few problems in your implementation, so I've took the
liberty of modifying it I've checked it in so that anybody with commit
rights can modify the code. Here it is :

http://svn.apache.org/repos/asf/httpd/mod_python/trunk/lib/python/mod_python/FileSession.py

Basically, I've added a few try...finally to make sure that opened
files are closed, but I've not done anything yet about the tempdir
issue, the locking issue or changing the pickling protocol. It's
coming soon.

Eventually, we could bring back the FileSession class into the Session
module ; I've put it in its own file for now so that we don't bring
too much noise with this new feature. Ideally I should build a branch
for this but I'm not too self-confident about branching and merging in
subversion...

Regards,
Nicolas


More information about the Mod_python mailing list