quetz-mod_python-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicolas Lehuen <nicolas.leh...@gmail.com>
Subject Re: release? FileSession.py
Date Thu, 28 Apr 2005 08:17:23 GMT
On 4/28/05, Nicolas Lehuen <nicolas.lehuen@gmail.com> wrote:
> On 4/27/05, dharana <dharana@dharana.net> wrote:
> > Jim Gallacher wrote:
> > > Nicolas Lehuen wrote:
> > >
> > > [...]
> > >
> > > Attached is my latest and hopefully greatest. :)  This version uses the
> > > grace_period idea to avoid race and/or deadlock issues and correctly
> > > register the filesession_cleanup method to run at the end of a request.
> 
> Thanks, I'll integrate this ASAP tomorrow morning (it's too late for now :).

OK, this is done.

> > > In the original code there was a comment (from dharana?) about a random
> > > EOFError in the do_load method. I have not been able to reproduce this
> > > error but I left the comment in anyway.
> >
> > No, it's not mine. I have yet to see it happen.
> 
> It was mine. The bug is totally reproducible, on my machine at least.
> I'll investigate this a little more tomorrow.

Found it. It turns out that we need to open the session file in binary
mode for reading and writing.

I've never really understood why, but on Win32 files can be opened in
text mode, in which some control characters mean an EOF. If you try to
write binary data in a text-mode file, and your binary data contains
an EOF character, then you're out of luck. You have to open the file
in binary mode, by adding an 'b' to the mode.

What lead to to find this was that when using the text-friendly
pickling protocol 0, there was no problem. The bug only appeared when
using the binary pickling protocol 2.

OK so now I think we have a pretty good implementation of FileSession :)

Regards,
Nicolas

> > >
> > > Also, my comments for the filesession_cleanup function are rather
> > > verbose. Feel free to trim them as you see fit.
> > >
> > > Regards,
> > > Jim
> >
> > I have tested this version's performance which was the driving force
> > behind the initial suggestion. Performance-wise, this FileSession
> > version is as fast as the first rough one without locking, grace times,
> > etc. The difference is less than 1 req/s in the 165 req/s' range.
> >
> > I've switched my dev app to it and i will be using it daily from now on.
> >
> > --
> > dharana
> 
> Great ! Please give us your feedback on the behaviour of the new FileSession.
> 
> Regards,
> 
> Nicolas
>

Mime
View raw message