[mod_python] Sessions performance and some numbers

Nicolas Lehuen nicolas.lehuen at gmail.com
Thu Apr 7 19:01:00 EDT 2005


On Apr 8, 2005 12:10 AM, Graham Dumpleton <grahamd at dscpl.com.au> wrote:
> 
> On 08/04/2005, at 7:42 AM, Graham Dumpleton wrote:
> 
> > I am going to show my ignorance of how sessions are internally
> > implemented
> > here, ....
> 
> Another silly question about something I was wandering about recently
> when adding support for login hooks into Vampire in order to support
> session based login mechanisms.
> 
> The question is, if one doesn't explicitly invalidate a session, how
> does its record get deleted from the session database? How would such
> an inactive/expired sessions be cleaned out in a file based mechanism
> where there is one file per session?
> 
> Anyway, probably time to start looking at the code to work it out
> myself.
> Thought I would still ask though. :-)
> 
> Graham

The method used to do this is strange but it may work. Each time a
Session is loaded, a random test is performed to see whether sessions
must be cleaned or not. If the test succeeds (by default, you have one
chance on 1000), the session are cleaned : depending on the subclass,
each session's timeout is checked, and if a session gets too old, it
is deleted.

The session manager I have implemented uses a special "garbage
collecting" thread, but it's not portable to environments where
threading is not available. So I guess this method is the simplest one
that could do the task...

Regards,
Nicolas


More information about the Mod_python mailing list