https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/psycopg2/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/psycopg2/__pycache__/pool.cpython-310.pyc
o


��a��@s\dZddlZddlmZGdd�dej�ZGdd�d�ZGdd	�d	e�ZGd
d�de�ZdS)z`Connection pooling for psycopg2

This module implements thread-safe (and not) connection pools.
�N)�
extensionsc@seZdZdS)�	PoolErrorN)�__name__�
__module__�__qualname__�rr�//usr/lib/python3/dist-packages/psycopg2/pool.pyr src@sFeZdZdZdd�Zddd�Zdd�Zdd	d
�Zddd
�Zdd�Z	dS)�AbstractConnectionPoolzGeneric key-based pooling code.cOsZt|�|_t|�|_d|_||_||_g|_i|_i|_d|_	t
|j�D]}|��q$dS)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__NcCsHtj|ji|j��}|dur||j|<||jt|�<|S|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�_getkeyGszAbstractConnectionPool._getkeycCs�|jrtd��|dur|��}||jvr|j|S|jr/|j��|j|<}||jt|�<|St|j�|j	kr;td��|�
|�S)�9Get a free connection and assign it to 'key' if not None.�connection pool is closedNzconnection pool exhausted)r
rr$rr�poprr�lenrrrrrr�_getconnLs


zAbstractConnectionPool._getconnFcCs�|jrtd��|dur|j�t|��}|durtd��t|j�|jkrM|sM|jsL|jj	}|t
jkr6|��n|t
j
krF|��|j�|�n|j�|�n|��|jrY||jvre|j|=|jt|�=dSdS)zPut away a connection.r&Nz trying to put unkeyed connection)r
rr�getrr(rr�info�transaction_status�_ext�TRANSACTION_STATUS_UNKNOWN�close�TRANSACTION_STATUS_IDLE�rollbackrr)rr!r r/�statusrrr�_putconn_s*


��zAbstractConnectionPool._putconnc	CsP|jrtd��|jt|j���D]}z|��Wqty"Yqwd|_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.
        r&TN)r
rr�listr�valuesr/�	Exception)rr!rrr�	_closeall�s�
z AbstractConnectionPool._closeall�N)NF)
rrr�__doc__rrr$r)r3r7rrrrr	$s



#r	c@s"eZdZdZejZejZej	Z
dS)�SimpleConnectionPoolz@A connection pool that can't be shared across different threads.N)rrrr9r	r)�getconnr3�putconnr7�closeallrrrrr:�s

r:c@s4eZdZdZdd�Zddd�Zd
dd	�Zd
d�ZdS)�ThreadedConnectionPoolz7A connection pool that works with the threading module.cOs2ddl}tj|||g|�Ri|��|��|_dS)zInitialize the threading lock.rN)�	threadingr	r�Lock�_lock)rrrrrr?rrrr�s���zThreadedConnectionPool.__init__NcCs.|j��z|�|�W|j��S|j��w)r%)rA�acquirer)�release)rr rrrr;�s

zThreadedConnectionPool.getconnFcCs6|j��z|�|||�W|j��dS|j��w)zPut away an unused connection.N)rArBr3rC)rr!r r/rrrr<�s
zThreadedConnectionPool.putconncCs0|j��z|��W|j��dS|j��w)z6Close all connections (even the one currently in use.)N)rArBr7rCr#rrrr=�s

zThreadedConnectionPool.closeallr8)NNF)rrrr9rr;r<r=rrrrr>�s

r>)	r9rrr-�Errorrr	r:r>rrrr�<module>so

https://t.me/RX1948 - 2025