ó Tc@s–dZddlZddljZdejfd„ƒYZdefd„ƒYZdefd„ƒYZ d efd „ƒYZ d efd „ƒYZ dS( s`Connection pooling for psycopg2 This module implements thread-safe (and not) connection pools. iÿÿÿÿNt PoolErrorcBseZRS((t__name__t __module__(((s@/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/pool.pyRstAbstractConnectionPoolcBsPeZdZd„Zdd„Zd„Zdd„Zded„Z d„Z RS(sGeneric key-based pooling code.cOs…t|ƒ|_t|ƒ|_t|_||_||_g|_i|_i|_ d|_ x!t |jƒD]}|j ƒqmWdS(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( tinttminconntmaxconntFalsetclosedt_argst_kwargst_poolt_usedt_rusedt_keystranget_connect(tselfRRtargstkwargsti((s@/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/pool.pyt__init__&s       cCs[tj|j|jŽ}|dk rG||j|<||jt|ƒeZdZd„Zdd„Zdded„Zd„ZRS(s7A connection pool that works with the threading module.cOs8ddl}tj|||||Ž|jƒ|_dS(sInitialize the threading lock.iÿÿÿÿN(t threadingRRtLockt_lock(RRRRRR4((s@/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/pool.pyR˜s cCs3|jjƒz|j|ƒSWd|jjƒXdS(s9Get a free connection and assign it to 'key' if not None.N(R6tacquireR trelease(RR((s@/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/pool.pyR0Ÿs cCs9|jjƒz|j|||ƒWd|jjƒXdS(sPut away an unused connection.N(R6R7R)R8(RRRR%((s@/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/pool.pyR1§s cCs0|jjƒz|jƒWd|jjƒXdS(s6Close all connections (even the one currently in use.)N(R6R7R-R8(R((s@/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/pool.pyR2¯s N( RRR.RRR0RR1R2(((s@/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/pool.pyR3•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. cOsiddl}|jdtƒddl}tj|||||Ž|jƒ|_ddl}||_ dS(sInitialize the threading lock.iÿÿÿÿNs.deprecated: use ZPsycopgDA.pool implementation( twarningstwarntDeprecationWarningR4RRR5R6tthreadt!_PersistentConnectionPool__thread(RRRRRR:R4R=((s@/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/pool.pyRÂs    cCsB|jjƒ}|jjƒz|j|ƒSWd|jjƒXdS(s+Generate thread id and return a connection.N(R>t get_identR6R7R R8(RR((s@/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/pool.pyR0Òs  cCs^|jjƒ}|jjƒz-|s5|j|}n|j|||ƒWd|jjƒXdS(sPut away an unused connection.N(R>R?R6R7R R)R8(RRR%R((s@/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/pool.pyR1Ûs cCs0|jjƒz|jƒWd|jjƒXdS(s6Close all connections (even the one currently in use.)N(R6R7R-R8(R((s@/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/pool.pyR2ås N( RRR.RR0RRR1R2(((s@/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/pool.pyR9¸s    ( R.Rtpsycopg2.extensionst extensionsR#tErrorRtobjectRR/R3R9(((s@/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/pool.pyts j#