Ñò žÅŠKc @sedZddkZyuddkZeideiddƒeidƒZd„ZyddkZei dƒWnei dƒnXWnfe j o?dd k l Z lZlZd „Ze d ed d ƒnddkZd„ZnXdeifd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdS(s`Connection pooling for psycopg2 This module implements thread-safe (and not) connection pools. iÿÿÿÿNtleveltformats%%(asctime)s %(levelname)s %(message)stpsycopg2cGs>tiddig}|D]}|t|ƒq~ƒƒdS(NRt (t_loggertdebugtjointstr(targst_[1]tx((s3/usr/lib64/python2.6/site-packages/psycopg2/pool.pytdbg$ss.installed. Logging using Python logging module(tLOGtDEBUGtINFOc GsEtdtddig}|D]}|t|ƒq~ƒdƒdS(Nt ZPsycopgDAtRs (R R RR(RR R ((s3/usr/lib64/python2.6/site-packages/psycopg2/pool.pyR .s Rt InstalledsLogging using Zope's zLOG cGs!tiidi|ƒdƒdS(NRs (tsyststderrtwriteR(R((s3/usr/lib64/python2.6/site-packages/psycopg2/pool.pyR 5st PoolErrorcBseZRS((t__name__t __module__(((s3/usr/lib64/python2.6/site-packages/psycopg2/pool.pyR9stAbstractConnectionPoolcBsPeZdZd„Zdd„Zd„Zdd„Zded„Z d„Z RS(sGeneric key-based pooling code.cOsy||_||_t|_||_||_g|_h|_h|_d|_ x!t |iƒD]}|i ƒqaWdS(sðInitialize the connection pool. New 'minconn' connections are created immediately calling 'connfunc' with given parameters. The connection pool will support a maximum of about 'maxconn' connections. iN( tminconntmaxconntFalsetclosedt_argst_kwargst_poolt_usedt_rusedt_keystranget_connect(tselfRRRtkwargsti((s3/usr/lib64/python2.6/site-packages/psycopg2/pool.pyt__init__@s         cCs]ti|i|iŽ}|dj o$||i|<||it|ƒeZdZd„Zdd„Zdded„Zd„ZRS(s7A connection pool that works with the threading module.cOs8ddk}ti|||||Ž|iƒ|_dS(sInitialize the threading lock.iÿÿÿÿN(t threadingRR(tLockt_lock(R%RRRR&R@((s3/usr/lib64/python2.6/site-packages/psycopg2/pool.pyR(¤s cCs3|iiƒz|i|ƒSWd|iiƒXdS(s9Get a free connection and assign it to 'key' if not None.N(RBtacquireR3trelease(R%R-((s3/usr/lib64/python2.6/site-packages/psycopg2/pool.pyR<«s cCs9|iiƒz|i|||ƒWd|iiƒXdS(sPut away an unused connection.N(RBRCR5RD(R%R.R-R4((s3/usr/lib64/python2.6/site-packages/psycopg2/pool.pyR=³s cCs0|iiƒz|iƒWd|iiƒXdS(s6Close all connections (even the one currently in use.)N(RBRCR9RD(R%((s3/usr/lib64/python2.6/site-packages/psycopg2/pool.pyR>»s N( RRR:R(R*R<RR=R>(((s3/usr/lib64/python2.6/site-packages/psycopg2/pool.pyR?¡s   tPersistentConnectionPoolcBs8eZdZd„Zd„Zded„Zd„ZRS(s›A pool that assigns persistent connections to different threads. Note that this connection pool generates by itself the required keys using the current thread id. This means that until a thread puts away a connection it will always get the same connection object by successive `!getconn()` calls. This also means that a thread can't use more than one single connection from the pool. cOsMddk}ti|||||Ž|iƒ|_ddk}||_dS(sInitialize the threading lock.iÿÿÿÿN(R@RR(RARBtthreadt!_PersistentConnectionPool__thread(R%RRRR&R@RF((s3/usr/lib64/python2.6/site-packages/psycopg2/pool.pyR(Îs   cCsB|iiƒ}|iiƒz|i|ƒSWd|iiƒXdS(s+Generate thread id and return a connection.N(RGt get_identRBRCR3RD(R%R-((s3/usr/lib64/python2.6/site-packages/psycopg2/pool.pyR<Ús  cCs`|iiƒ}|iiƒz/|p|i|}n|i|||ƒWd|iiƒXdS(sPut away an unused connection.N(RGRHRBRCR R5RD(R%R.R4R-((s3/usr/lib64/python2.6/site-packages/psycopg2/pool.pyR=ãs cCs0|iiƒz|iƒWd|iiƒXdS(s6Close all connections (even the one currently in use.)N(RBRCR9RD(R%((s3/usr/lib64/python2.6/site-packages/psycopg2/pool.pyR>ís N( RRR:R(R<R*RR=R>(((s3/usr/lib64/python2.6/site-packages/psycopg2/pool.pyREÄs   (R:Rtloggingt basicConfigRt getLoggerRR tApptinfoRt ImportErrortzLOGR R RtErrorRtobjectRR;R?RE(((s3/usr/lib64/python2.6/site-packages/psycopg2/pool.pyts0       \#