[mod_python] persistence in mod_python

Simon Bierbaum bierbaum at vierfalt.com
Fri Aug 22 04:12:38 EDT 2008


I solved the problem in the meantime. There was an SQLAlchemy session  
object I did not clean up with close() properly after finishing up a  
request. It still lived in the second request, resulting in correct  
data being fetched from the database, but an out-of-date object still  
present in the session was returned. Thanks again for your help :-)

Simon

Am 22.08.2008 um 02:28 schrieb Graham Dumpleton:

> 2008/8/21 Simon Bierbaum <bierbaum at vierfalt.com>:
>> Thanks, Graham. From reading this and also
>> http://www.dscpl.com.au/wiki/ModPython/Articles/ 
>> ModuleImportingIsBroken, I
>> believe that two distinct requests, handled consecutively by the same
>> unrecycled apache prefork child, will see the same global module  
>> objects and
>> thus the same module state. Is that correct?
>
> Yes.
>
>> I know this data sharing method
>> should not be used,
>
> The sharing method can be used, but not for stuff that must be the
> same across all processes. Thus you can still use module global data
> for caching information which is effectively read only and where if
> necessary you have checks to ensure it is refreshed as needed.
>
>> but it would mean the bug I'm hunting could be caused by
>> some unintentionally left over state within a module, making the  
>> second
>> request work with stale data.
>
> It could also be due to that caching mechanism not being threaded
> protected properly. For example, if one request is updating the cache
> will a concurrent request in same process is using data from the
> cache.
>
> Without know more detail about the problem you are seeing and example
> code showing how you are using global module data, had to say.
>
> Graham
>
>> Am 20.08.2008 um 22:43 schrieb Graham Dumpleton:
>>
>>> For a start, read:
>>>
>>>
>>>  http://www.dscpl.com.au/wiki/ModPython/Articles/ 
>>> TheProcessInterpreterModel
>>>
>>> Graham
>>>
>>> 2008/8/21 Simon Bierbaum <bierbaum at vierfalt.com>:
>>>>
>>>> Hi all,
>>>>
>>>> I would like to know exactly what bits in mod_python are persistent
>>>> across
>>>> multiple requests to the same apache process. I.e., once apache is
>>>> started
>>>> and mod_python is loaded, between two requests served by the  
>>>> same apache
>>>> process and the same Python handler,
>>>>
>>>> - does mod_python reload modules, i.e. is module initialization  
>>>> code only
>>>> run once during the apache process lifespan?
>>>> - is there a way for modules to store objects persistently, e.g. a
>>>> database
>>>> connection pool?
>>>> - what happens to variables defined in the handler script but  
>>>> not locally
>>>> within the handler() function (I'm not sure whether this is what  
>>>> Python
>>>> calls "global")?
>>>>
>>>> I have a bug in my application which uses mod_python, MySQLdb  
>>>> and the
>>>> InnoDB
>>>> storage engine revolving around transactions, and it's driving me
>>>> mad...any
>>>> help or a pointer to documentation is greatly appreciated.
>>>>
>>>> Thanks, Simon
>>>> _______________________________________________
>>>> Mod_python mailing list
>>>> Mod_python at modpython.org
>>>> http://mailman.modpython.org/mailman/listinfo/mod_python
>>>>
>>
>> _______________________________________________
>> Mod_python mailing list
>> Mod_python at modpython.org
>> http://mailman.modpython.org/mailman/listinfo/mod_python
>>



More information about the Mod_python mailing list