database connection pooling from mod_python app
Ian Bicking
ianb at colorstudy.com
Wed Oct 8 13:12:35 EDT 2003
On Wednesday, October 8, 2003, at 11:23 AM, Anthony_Barker wrote:
> I have been searching around for database connection pooling for a
> mod_python app.
My understanding is that you don't really need connection pooling in
mod_python -- you can simply put the connection in a global variable.
Maybe with something like:
def get_connection():
global _conn
try:
return _conn
except NameError:
_conn = (make your connection)
return _conn
I don't know mod_python enough to know if there's other magic
incantations you need. You don't need "pooling", because each request
is served in its own process -- you simply want to reuse the connection
for future requests. If there's 10 processes, you'll need 10 separate
connections, but those 10 processes will over time serve many requests
so you can use those 10 connections over and over.
So this isn't direct advise -- you'll need to experiment on your own --
but I'd suggest you not overthink it. I think it's simpler than you
think.
--
Ian Bicking | ianb at colorstudy.com | http://blog.ianbicking.org
More information about the Python-list
mailing list