[Twisted-Python] implementing an adbapi connectionpool idle timer

Phil Mayers p.mayers at imperial.ac.uk
Sun Jun 10 08:04:58 EDT 2007


I'm using t.e.adbapi with psycopg against a Postgres 8 database. This 
database is replicated using Slony-I and I'm hitting this problem:


Basically, holding open SQL connections for a long time causes postgres 
to cache query plans; these cached plans need to be freed for Slony to 
rollover its internal SQL replication log table.

So I'd like to add something to ConnectionPool to disconnect unused 
connections after a certain time. Any suggestions how to start?

Also - looking at the ConnectionPool/Transaction code, it appears a 
ConnectionPool's "connections" dictionary is modified from multiple 
threads without locking. Is this safe?

More information about the Twisted-Python mailing list