ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib/python3.11/site-packages/psycopg2/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/psycopg2/__pycache__/pool.cpython-311.pyc

�

�܋f����dZddlZddlmZGd�dej��ZGd�d��ZGd�d	e��ZGd
�de��ZdS)z`Connection pooling for psycopg2

This module implements thread-safe (and not) connection pools.
�N)�
extensionsc��eZdZdS)�	PoolErrorN)�__name__�
__module__�__qualname__���`/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib64/python3.11/site-packages/psycopg2/pool.pyrr s�������Dr
rc�<�eZdZdZd�Zd
d�Zd�Zd
d�Zdd�Zd	�Z	dS)�AbstractConnectionPoolzGeneric key-based pooling code.c��t|��|_t|��|_d|_||_||_g|_i|_i|_d|_	t|j��D]}|����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�is      r�__init__zAbstractConnectionPool.__init__'s����7�|�|����7�|�|��������
������
���
������
��t�|�$�$�	�	�A��M�M�O�O�O�O�	�	r
Nc��tj|ji|j��}|�"||j|<||jt
|��<n|j�|��|S)z;Create a new connection and assign it to 'key' if not None.)	�psycopg2�connectrrrr�idr�append�r�key�conns   rrzAbstractConnectionPool._connect=s[������<�t�|�<�<���?�"�D�J�s�O�$'�D�K��4���!�!��J���d�#�#�#��r
c�0�|xjdz
c_|jS)zReturn a new unique key.�)r�rs r�_getkeyzAbstractConnectionPool._getkeyGs���
�
�a��
�
��z�r
c��|jrtd���|�|���}||jvr
|j|S|jr<|j���x|j|<}||jt|��<|St|j��|j	krtd���|�
|��S)�9Get a free connection and assign it to 'key' if not None.�connection pool is closedNzconnection pool exhausted)rrr+rr�poprr#�lenrrr%s   r�_getconnzAbstractConnectionPool._getconnLs����;�	9��7�8�8�8��;��,�,�.�.�C��$�*����:�c�?�"��:�	&�%)�Z�^�^�%5�%5�5�D�J�s�O�d�$'�D�K��4���!��K��4�:���$�,�.�.�� ;�<�<�<��=�=��%�%�%r
Fc��|jrtd���|�8|j�t	|����}|�td���t|j��|jkr�|s�|js�|jj	}|tjkr|���nn|tj
kr/|���|j�|��n/|j�|��n|���|jr	||jvr|j|=|jt	|��=dSdS)zPut away a connection.r.Nz trying to put unkeyed connection)rrr�getr#r0rr�info�transaction_status�_ext�TRANSACTION_STATUS_UNKNOWN�close�TRANSACTION_STATUS_IDLE�rollbackr$r)rr'r&r8�statuss     r�_putconnzAbstractConnectionPool._putconn_s5���;�	9��7�8�8�8��;��+�/�/�"�T�(�(�+�+�C��{�� B�C�C�C��t�z�?�?�T�\�)�)�%�)��;�
,���5���T�<�<�<��J�J�L�L�L�L��t�;�;�;��M�M�O�O�O��J�%�%�d�+�+�+�+��J�%�%�d�+�+�+��
�J�J�L�L�L��{�	&�c�T�Z�/�/��
�3����B�t�H�H�%�%�%�0�/r
c���|jrtd���|jt|j�����zD]'}	|����#t$rY�$wxYwd|_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)rrr�listr�valuesr8�	Exception)rr's  r�	_closeallz AbstractConnectionPool._closeall�s����;�	9��7�8�8�8��J��d�j�&7�&7�&9�&9�!:�!:�:�	�	�D�
��
�
�������
�
�
���
��������s�A�
A*�)A*�N)NF)
rrr�__doc__rrr+r1r<rAr	r
rr
r
$s�������)�)����,�������
&�&�&�&�&!&�!&�!&�!&�F����r
r
c�<�eZdZdZejZejZej	Z
dS)�SimpleConnectionPoolz@A connection pool that can't be shared across different threads.N)rrrrCr
r1�getconnr<�putconnrA�closeallr	r
rrErE�s,������J�J�$�-�G�$�-�G�%�/�H�H�Hr
rEc�.�eZdZdZd�Zdd�Zd	d�Zd�ZdS)
�ThreadedConnectionPoolz7A connection pool that works with the threading module.c�n�ddl}tj|||g|�Ri|��|���|_dS)zInitialize the threading lock.rN)�	threadingr
r�Lock�_lock)rrrrrrLs      rrzThreadedConnectionPool.__init__�sY�������'��'�7�	5�%)�	5�	5�	5�-3�	5�	5�	5��^�^�%�%��
�
�
r
Nc���|j���	|�|��|j���S#|j���wxYw)r-)rN�acquirer1�release)rr&s  rrFzThreadedConnectionPool.getconn�s[���
������	!��=�=��%�%��J��� � � � ��D�J��� � � � ���s�A	�	A$Fc���|j���	|�|||��|j���dS#|j���wxYw)zPut away an unused connection.N)rNrPr<rQ)rr'r&r8s    rrGzThreadedConnectionPool.putconn�se���
������	!��M�M�$��U�+�+�+��J��� � � � � ��D�J��� � � � ���s�A
�
A(c���|j���	|���|j���dS#|j���wxYw)z6Close all connections (even the one currently in use.)N)rNrPrArQr*s rrHzThreadedConnectionPool.closeall�s_���
������	!��N�N�����J��� � � � � ��D�J��� � � � ���s�A
�
A%rB)NNF)rrrrCrrFrGrHr	r
rrJrJ�s`������A�A�&�&�&�!�!�!�!�!�!�!�!�!�!�!�!�!r
rJ)	rCr!rr6�Errorrr
rErJr	r
r�<module>rUs�����6����'�'�'�'�'�'�	�	�	�	�	���	�	�	�l�l�l�l�l�l�l�l�^0�0�0�0�0�1�0�0�0� !� !� !� !� !�3� !� !� !� !� !r

Zerion Mini Shell 1.0