[mod_python] Session.py: filesession_cleanup (I)

Jim Gallacher jpg at jgassociates.ca
Fri Nov 9 09:29:05 EST 2007


David Janes wrote:
> I'm getting random hangs on a mod_python based system under moderately 
> load. I haven't tracked down the problem yet, but based on some error 
> logging I've been doing code inspection and have a few comments/questions.
> 
> (1)
> In Session.py, function filesession_cleanup, lines 624-638 there's a 
> try/except block that returns on an exception. However, to get to this 
> block, 'lockfp' has to be open -- and there is no close in the exception 
> block.
> 
> Should not this code block be moved inside the next try/finally block 
> which ensures the file object is closed?

I don't have time to review the code right now. I'll look at it later today.

> (2)
> In my logs I am getting the error message
> 
> python_cleanup: Error calling cleanup object <function 
> filesession_cleanup at 0xb7b22924>
> exceptions.TypeError: not enough arguments for format string
> 
> The likely culprit for this error is line 705 (-707):
> 
>             req.log_error("FileSession cleanup incomplete: next cleanup 
> will start at index %d (%02x)"
>                         % (next_i,),
>                         apache.APLOG_NOTICE)
> 
> Does this make sense?

No, and I don't know how this slipped through my testing when I wrote 
this code. :(

It should read:

req.log_error("FileSession cleanup incomplete: next cleanup will start 
at index %d (%02x)"
                         % (next_i, next_i),
                         apache.APLOG_NOTICE)

Jim


More information about the Mod_python mailing list