[mod_python] connection pool (newbie question)

Graham Dumpleton grahamd at dscpl.com.au
Wed Dec 14 16:07:13 EST 2005

On 15/12/2005, at 12:32 AM, Mike Looijmans wrote:

>> I've looked at connection pool code for a persistent database
>> connection.   I don't know where to create the connection pool.
>> If in the handler code (I'm using publisher), wouldn't a new
>> pool be created each time the handler is called?
> You'll get a new pool for each process (not for each thread)

Technically speaking, not necessarily. :-)

There will actually be one per Python interpreter instance which uses  
handler module. Thus if you were supporting two virtual hosts and  
both used
the same handler module there would be one for each virtual host in each
process. This even presumes the pool was created at global scope within
the handler module. If it was created within the handler function  
itself, then
there could be one per request.

If pool was created at global scope within the handler module and module
reloading is used, then over time you could end up with multiple  
pools with
older ones potentially becoming inaccessible resources with a  
resource leak
resulting. Resource pools should ideally be created in modules which are
not the subject of mod_python module reloading.

All this was what the referenced article and old mailing list posts  
help to


More information about the Mod_python mailing list