HEX
Server: LiteSpeed
System: Linux ws4.angoweb.net 5.14.0-611.13.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 11 04:57:59 EST 2025 x86_64
User: tswangoe (2287)
PHP: 8.1.33
Disabled: show_source, system, shell_exec, passthru, exec, phpinfo, popen, proc_open
Upload Files
File: //opt/alt/python37/lib64/python3.7/site-packages/psycopg2/__pycache__/pool.cpython-37.pyc
B

^l�h�
L�@s^dZddlZddlmZGdd�dej�ZGdd�de�ZGdd	�d	e�ZGd
d�de�Z	dS)z`Connection pooling for psycopg2

This module implements thread-safe (and not) connection pools.
�N)�
extensionsc@seZdZdS)�	PoolErrorN)�__name__�
__module__�__qualname__�rr�@/opt/alt/python37/lib64/python3.7/site-packages/psycopg2/pool.pyrsrc@sFeZdZdZdd�Zddd�Zdd�Zdd	d
�Zddd
�Zdd�Z	dS)�AbstractConnectionPoolzGeneric key-based pooling code.cOs^t|�|_t|�|_d|_||_||_g|_i|_i|_d|_	xt
|j�D]}|��qJWdS)z�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.
        FrN)�int�minconn�maxconn�closed�_args�_kwargs�_pool�_used�_rused�_keys�range�_connect)�selfrr�args�kwargs�irrr�__init__&s

zAbstractConnectionPool.__init__NcCsBtj|j|j�}|dk	r2||j|<||jt|�<n|j�|�|S)z;Create a new connection and assign it to 'key' if not None.N)	�psycopg2�connectrrrr�idr�append)r�key�connrrrr<s
zAbstractConnectionPool._connectcCs|jd7_|jS)zReturn a new unique key.�)r)rrrr�_getkeyFszAbstractConnectionPool._getkeycCs�|jrtd��|dkr|��}||jkr2|j|S|jr^|j��|j|<}||jt|�<|St|j�|j	krvtd��|�
|�SdS)z9Get a free connection and assign it to 'key' if not None.zconnection pool is closedNzconnection pool exhausted)r
rr"rr�poprr�lenrr)rrr rrr�_getconnKs

zAbstractConnectionPool._getconnFcCs�|jrtd��|dkr6|j�t|��}|dkr6td��t|j�|jkr�|s�|js�|jj	}|t
jkrl|��q�|t
j
kr�|��|j�|�q�|j�|�n|��|jr�||jkr�|j|=|jt|�=dS)zPut away a connection.zconnection pool is closedNz trying to put unkeyed connection)r
rr�getrr$rr�infoZtransaction_status�_extZTRANSACTION_STATUS_UNKNOWN�closeZTRANSACTION_STATUS_IDLEZrollbackrr)rr rr)�statusrrr�_putconn^s&


zAbstractConnectionPool._putconnc	CsX|jrtd��x>|jt|j���D]&}y|��Wq$tk
rHYq$Xq$Wd|_dS)z�Close all connections.

        Note that this can lead to some code fail badly when trying to use
        an already closed connection. If you call .closeall() make sure
        your code can deal with it.
        zconnection pool is closedTN)r
rr�listr�valuesr)�	Exception)rr rrr�	_closeall�s
z AbstractConnectionPool._closeall)N)N)NF)
rrr�__doc__rrr"r%r+r/rrrrr	#s



#r	c@s"eZdZdZejZejZej	Z
dS)�SimpleConnectionPoolz@A connection pool that can't be shared across different threads.N)rrrr0r	r%�getconnr+�putconnr/�closeallrrrrr1�sr1c@s4eZdZdZdd�Zddd�Zd
dd	�Zd
d�ZdS)�ThreadedConnectionPoolz7A connection pool that works with the threading module.cOs,ddl}tj|||f|�|�|��|_dS)zInitialize the threading lock.rN)�	threadingr	r�Lock�_lock)rrrrrr6rrrr�szThreadedConnectionPool.__init__NcCs&|j��z
|�|�S|j��XdS)z9Get a free connection and assign it to 'key' if not None.N)r8�acquirer%�release)rrrrrr2�s

zThreadedConnectionPool.getconnFcCs.|j��z|�|||�Wd|j��XdS)zPut away an unused connection.N)r8r9r+r:)rr rr)rrrr3�s
zThreadedConnectionPool.putconncCs(|j��z|��Wd|j��XdS)z6Close all connections (even the one currently in use.)N)r8r9r/r:)rrrrr4�s
zThreadedConnectionPool.closeall)N)NNF)rrrr0rr2r3r4rrrrr5�s


r5)
r0rrr(�Errorr�objectr	r1r5rrrr�<module>so