[mod_python] Session data (Sorry for bringing this up again...)

piet at cs.uu.nl piet at cs.uu.nl
Tue Jul 3 09:51:00 EST 2001


>>>>> Ben Leslie <benno at sesgroup.net> (BL) writes:

BL> On Tue, 03 Jul 2001, Matthew Wood wrote:
BL> <snip>

>> 
>> This brings me to my question:
>> Would  it  be appropriate to keep a database connection in each of the
>> memory  spaces?


BL> Yes. This is exactly what I do.

BL> In your handler you have a global variable holding the db connection. In 
BL> the handler you check the db handler is alive and recreate if necessary 
BL> (this should really only happen the first time that process is used)

You would have to be careful with multithreading. This applies to Apache on
MS Windows and with 2.0 also on Unix systems. You would need a connection
per thread. Or have a pool where each thread can try to grab a connection.
The pool administration would have to be protected with semaphores or locks
or similar. 
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl




More information about the Mod_python mailing list