PK APOCALYPSE V1

APOCALYPSE V1

Current Path : /opt/hc_python/lib/python3.12/site-packages/sqlalchemy/pool/__pycache__/
Upload File :
Current File : //opt/hc_python/lib/python3.12/site-packages/sqlalchemy/pool/__pycache__/base.cpython-312.pyc

�

���gQ���B�UdZddlmZddlmZddlZddlmZddlZddl	Z	ddl
Z
ddl
mZddl
mZddl
m
Z
dd	l
mZdd
l
mZddl
mZddl
mZdd
l
mZddl
mZddl
mZddlZddlmZddlmZddlmZddlmZddlmZddlmZer*ddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddl%m&Z&ejNd��Gd �d!��Z(Gd"�d#e�Z)ee)ed$fZ*e+e)�\Z,Z-Z.Gd%�d&�Z/Gd'�d(e/�Z0Gd)�d*e�Z1Gd+�d,e�Z2Gd-�d.ejfejh�Z5Gd/�d0�Z6Gd1�d2e6�Z7Gd3�d4e7�Z8		d>															d?d5�Z9iZ:d6e;d7<Gd8�d9e6�Z<Gd:�d;e<�Z=Gd<�d=e<�Z>y)@z'Base constructs for connection pools.

�)�annotations)�dequeN)�Enum)�Any)�Callable)�cast)�Deque)�Dict)�List)�Optional)�Tuple)�
TYPE_CHECKING)�Union�)�event)�exc)�log)�util)�Literal)�Protocol)�DBAPIConnection)�DBAPICursor)�Dialect)�_DispatchCommon)�_ListenerFnType)�
dispatcher)�	_InfoTypeT)�frozenc�8�eZdZUdZdZded<	ded<	ded<y)�PoolResetStatez�describes the state of a DBAPI connection as it is being passed to
    the :meth:`.PoolEvents.reset` connection pool event.

    .. versionadded:: 2.0.0b3

    ��transaction_was_reset�terminate_only�asyncio_safe�boolr"r#r$N)�__name__�
__module__�__qualname__�__doc__�	__slots__�__annotations__���E/opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/pool/base.pyr r 2s4���L�I���
���	���r-r c��eZdZdZdZdZdZy)�
ResetStylez1Describe options for "reset on return" behaviors.r�rN)r&r'r(r)�reset_rollback�reset_commit�
reset_noner,r-r.r0r0_s��;��N��L��Jr-r0)TNF�commit�rollbackc�H�eZdZdZdZdZd
d�Zd
d�Zdd�Zdd�Z	dd�Z
d
d�Zy	)�_ConnDialectz�partial implementation of :class:`.Dialect`
    which provides DBAPI connection methods.

    When a :class:`_pool.Pool` is combined with an :class:`_engine.Engine`,
    the :class:`_engine.Engine` replaces this with its own
    :class:`.Dialect`.

    Fc�$�|j�y�N)r6��self�dbapi_connections  r.�do_rollbackz_ConnDialect.do_rollback{s���!�!�#r-c�$�|j�yr:)r5r;s  r.�	do_commitz_ConnDialect.do_commit~s�����!r-c�$�|j�yr:��closer;s  r.�do_terminatez_ConnDialect.do_terminate������� r-c�$�|j�yr:rBr;s  r.�do_closez_ConnDialect.do_close�rEr-c��td��)NzJThe ping feature requires that a dialect is passed to the connection pool.��NotImplementedErrorr;s  r.�_do_ping_w_eventz_ConnDialect._do_ping_w_event�s��!�
-�
�	
r-c��|Sr:r,)r<�
connections  r.�get_driver_connectionz"_ConnDialect.get_driver_connection�s���r-N)r=�PoolProxiedConnection�return�None)r=rrPrQ)r=rrPr%)rMrrPr)r&r'r(r)�is_async�
has_terminater>r@rDrGrKrNr,r-r.r8r8ns1����H��M�$�"�!�!�
�r-r8c��eZdZdZy)�_AsyncConnDialectTN)r&r'r(rRr,r-r.rUrU�s���Hr-rUc��eZdZdd�Zy)�_CreatorFnTypec��yr:r,�r<s r.�__call__z_CreatorFnType.__call__�s��3r-N�rPr�r&r'r(rZr,r-r.rWrW�s��.r-rWc��eZdZdd�Zy)�_CreatorWRecFnTypec��yr:r,�r<�recs  r.rZz_CreatorWRecFnType.__call__�s��Sr-N)ra�ConnectionPoolEntryrPrr\r,r-r.r^r^�s��Hr-r^c��eZdZUdZded<ded<ded<e�Zded	<d
ed<ded
<ded<								d#																	d$d�Zejd%d��Z
ed&d��Zej				d'd��Zejd(d��Z				d)d�Zdd�					d*d�Zd+d�Z		d,							d-d�Zd.d�Zd(d�Zd/d�Zd0d�Zd+d �Zd0d!�Zd1d"�Zy)2�Poolz)Abstract base class for connection pools.zdispatcher[Pool]�dispatch�log._EchoFlagType�echo�
Optional[str]�_orig_logging_namezUnion[_ConnDialect, Dialect]�_dialect�)Union[_CreatorFnType, _CreatorWRecFnType]�_creator_argr^�_invoke_creator�float�_invalidate_timeNFc
	���|r|x|_|_nd|_tj||��||_||_d|_||_tj|tjddgtjgd�tjdgid�|_||_|	r|j j#|	d	�
�|r||_|r"|D]\}
}t'j(|||
��yy)a4
        Construct a Pool.

        :param creator: a callable function that returns a DB-API
          connection object.  The function will be called with
          parameters.

        :param recycle: If set to a value other than -1, number of
          seconds between connection recycling, which means upon
          checkout, if this timeout is surpassed the connection will be
          closed and replaced with a newly opened connection. Defaults to -1.

        :param logging_name:  String identifier which will be used within
          the "name" field of logging records generated within the
          "sqlalchemy.pool" logger. Defaults to a hexstring of the object's
          id.

        :param echo: if True, the connection pool will log
         informational output such as when connections are invalidated
         as well as when connections are recycled to the default log handler,
         which defaults to ``sys.stdout`` for output..   If set to the string
         ``"debug"``, the logging will include pool checkouts and checkins.

         The :paramref:`_pool.Pool.echo` parameter can also be set from the
         :func:`_sa.create_engine` call by using the
         :paramref:`_sa.create_engine.echo_pool` parameter.

         .. seealso::

             :ref:`dbengine_logging` - further detail on how to configure
             logging.

        :param reset_on_return: Determine steps to take on
         connections as they are returned to the pool, which were
         not otherwise handled by a :class:`_engine.Connection`.
         Available from :func:`_sa.create_engine` via the
         :paramref:`_sa.create_engine.pool_reset_on_return` parameter.

         :paramref:`_pool.Pool.reset_on_return` can have any of these values:

         * ``"rollback"`` - call rollback() on the connection,
           to release locks and transaction resources.
           This is the default value.  The vast majority
           of use cases should leave this value set.
         * ``"commit"`` - call commit() on the connection,
           to release locks and transaction resources.
           A commit here may be desirable for databases that
           cache query plans if a commit is emitted,
           such as Microsoft SQL Server.  However, this
           value is more dangerous than 'rollback' because
           any data changes present on the transaction
           are committed unconditionally.
         * ``None`` - don't do anything on the connection.
           This setting may be appropriate if the database / DBAPI
           works in pure "autocommit" mode at all times, or if
           a custom reset handler is established using the
           :meth:`.PoolEvents.reset` event handler.

         * ``True`` - same as 'rollback', this is here for
           backwards compatibility.
         * ``False`` - same as None, this is here for
           backwards compatibility.

         For further customization of reset on return, the
         :meth:`.PoolEvents.reset` event hook may be used which can perform
         any connection activity desired on reset.

         .. seealso::

            :ref:`pool_reset_on_return`

            :meth:`.PoolEvents.reset`

        :param events: a list of 2-tuples, each of the form
         ``(callable, target)`` which will be passed to :func:`.event.listen`
         upon construction.   Provided here so that event listeners
         can be assigned via :func:`_sa.create_engine` before dialect-level
         listeners are applied.

        :param dialect: a :class:`.Dialect` that will handle the job
         of calling rollback(), close(), or commit() on DBAPI connections.
         If omitted, a built-in "stub" dialect is used.   Applications that
         make use of :func:`_sa.create_engine` should not use this parameter
         as it is handled by the engine creation strategy.

        :param pre_ping: if True, the pool will emit a "ping" (typically
         "SELECT 1", but is dialect-specific) on the connection
         upon checkout, to test if the connection is alive or not.   If not,
         the connection is transparently re-connected and upon success, all
         other pooled connections established prior to that timestamp are
         invalidated.     Requires that a dialect is passed as well to
         interpret the disconnection error.

         .. versionadded:: 1.2

        N)�echoflagrr6T)�noneNFr5�reset_on_returnF)�only_propagate)�logging_namerir�instance_logger�_creator�_recyclero�	_pre_pingr�parse_user_argument_for_enumr0r2r4r3�_reset_on_returnrgre�_updaterjr�listen)r<�creator�recyclergrurs�events�dialect�pre_ping�	_dispatch�fn�targets            r.�__init__z
Pool.__init__�s���X�:F�F�D��� 7�&*�D�#����D�4�0���
���
� !���!��� $� A� A���)�)�J��+=��%�%�'<��'�'�(��
�

�!
�����	���M�M�!�!�)�E�!�B��#�D�M��$�
��F����T�6�2�.�%�r-c�.�|jjSr:)rjrRrYs r.�_is_asynciozPool._is_asyncio3s���}�}�%�%�%r-c��|jSr:)rlrYs r.rwz
Pool._creator7s��� � � r-c�>�||_|j|�|_yr:)rl�_should_wrap_creatorrm)r<r~s  r.rwz
Pool._creator;s!��$��� $�8�8��A��r-c��|`|`yr:)rlrmrYs r.rwz
Pool._creatorEs��
��� r-c���	tj|jd��}|j�t|j�}nd}t|d�|z
}|d|dfdgdfk(rt	t|�S|dk(rt	t|�St	t
|���fd	�S#t$rt	t
|���fd�cYSwxYw)
zlDetect if creator accepts a single argument, or is sent
        as a legacy style no-arg function.

        T)�no_selfc�����Sr:r,�ra�
creator_fns �r.�<lambda>z+Pool._should_wrap_creator.<locals>.<lambda>W����z�|r-r��connection_recordr:r1c�����Sr:r,r�s �r.r�z+Pool._should_wrap_creator.<locals>.<lambda>jr�r-)	r�get_callable_argspecrw�	TypeErrorrrW�defaults�lenr^)r<r~�argspec�	defaulted�positionalsr�s     @r.r�zPool._should_wrap_creatorKs����	,��/�/��
�
�t�L�G�
���'��G�,�,�-�I��I��'�!�*�o�	�1��
�A�J���
�#�)<�(=�w�'G�G��*�G�4�4�
�A�
��*�G�4�4��n�g�6�J�+�+��+�	,��n�g�6�J�+�+�	,�s�!B#�#C�C��	terminatec�T�|jjd|rdnd|�	|r|jj|�y|jj	|�y#t
$rA}|jj
d|rdnd�d�|d�	�t|t�s�Yd}~yd}~wwxYw)
Nz%s connection %rzHard-closing�Closingz
Exception �terminating�closingz connection %rT��exc_info)	�logger�debugrjrDrG�
BaseException�error�
isinstance�	Exception)r<rMr��es    r.�_close_connectionzPool._close_connectionls���	
������'�N�Y��	
�

	���
�
�*�*�:�6��
�
�&�&�z�2���	��K�K����i�]�Y�G�H �!���	
�
��a��+��,��	�s�A�A�	B'�&7B"�"B'c��t|�S)z6Called by subclasses to create a new ConnectionRecord.)�_ConnectionRecordrYs r.�_create_connectionzPool._create_connection�s��!��&�&r-c���t|dd�}|r|j|jkrtj�|_|r t|dd�r|j	|�yyy)a�Mark all connections established within the generation
        of the given connection as invalidated.

        If this pool's last invalidate time is before when the given
        connection was created, update the timestamp til now.  Otherwise,
        no action is performed.

        Connections with a start time prior to this pool's invalidation
        time will be recycled upon next checkout.
        �_connection_recordN�is_validF)�getattrro�	starttime�time�
invalidate)r<rM�	exception�_checkinras     r.�_invalidatezPool._invalidate�sX�� �j�"6��=���d�+�+�c�m�m�;�$(�I�I�K�D�!���
�J��>��!�!�)�,�?�8r-c��t��)a"Return a new :class:`_pool.Pool`, of the same class as this one
        and configured with identical creation arguments.

        This method is used in conjunction with :meth:`dispose`
        to close out an entire :class:`_pool.Pool` and create a new one in
        its place.

        rIrYs r.�recreatez
Pool.recreate�s
��"�#�#r-c��t��)z�Dispose of this pool.

        This method leaves the possibility of checked-out connections
        remaining open, as it only affects connections that are
        idle in the pool.

        .. seealso::

            :meth:`Pool.recreate`

        rIrYs r.�disposezPool.dispose��
��"�#�#r-c�,�tj|�S)z�Return a DBAPI connection from the pool.

        The connection is instrumented such that when its
        ``close()`` method is called, the connection will be returned to
        the pool.

        )�_ConnectionFairy�	_checkoutrYs r.�connectzPool.connect�s�� �)�)�$�/�/r-c�&�|j|�y)z�Given a _ConnectionRecord, return it to the :class:`_pool.Pool`.

        This method is called when an instrumented DBAPI connection
        has its ``close()`` method called.

        N)�_do_return_conn�r<�records  r.�_return_connzPool._return_conn�s��	
���V�$r-c��t��)z7Implementation for :meth:`get`, supplied by subclasses.rIrYs r.�_do_getzPool._do_get��
��"�#�#r-c��t��)z?Implementation for :meth:`return_conn`, supplied by subclasses.rIr�s  r.r�zPool._do_return_conn�r�r-c��t��)z6Returns a brief description of the state of this pool.rIrYs r.�statuszPool.status����!�#�#r-)���NNTNNFN)r~rkr�intrgrfrurhrs�_ResetStyleArgTyper�z+Optional[List[Tuple[_ListenerFnType, str]]]r�z&Optional[Union[_ConnDialect, Dialect]]r�r%r�zOptional[_DispatchCommon[Pool]]�rPr%)rPrk)r~rkrPrQ�rPrQ)r~rkrPr^)rMrr�r%rPrQ)rPrb�NT)rMrOr��Optional[BaseException]r�r%rPrQ)rPrd)rPrO)r�rbrPrQ)rP�str)r&r'r(r)r+r8rjr�r�hybridpropertyr��propertyrw�setter�deleterr�r�r�r�r�r�r�r�r�r�r�r,r-r.rdrd�s���3���
��%�%�-9�^�H�*�;�;�;�'�'���
�"&�&*�.2�>B�:>��59�H/�:�H/��H/� �	H/�
$�H/�,�
H/�<�H/�8�H/��H/�3�H/�T
���&��&��!��!��_�_�B�@�B�	
�B��B����!��!�
,�@�,�	�,�DAF��)��9=��	
��.'�.2��	-�)�-�+�-��	-�

�-�,
$�
$�0�%�$�
$�
$r-rdc��eZdZUdZdZded<	ded<	ejdd��Zejdd��Z		d
					dd
�Z
y	)�ManagesConnectiona3Common base for the two connection-management interfaces
    :class:`.PoolProxiedConnection` and :class:`.ConnectionPoolEntry`.

    These two objects are typically exposed in the public facing API
    via the connection pool event hooks, documented at :class:`.PoolEvents`.

    .. versionadded:: 2.0

    r,�Optional[DBAPIConnection]r=�
Optional[Any]�driver_connectionc��t��)a�Info dictionary associated with the underlying DBAPI connection
        referred to by this :class:`.ManagesConnection` instance, allowing
        user-defined data to be associated with the connection.

        The data in this dictionary is persistent for the lifespan
        of the DBAPI connection itself, including across pool checkins
        and checkouts.  When the connection is invalidated
        and replaced with a new one, this dictionary is cleared.

        For a :class:`.PoolProxiedConnection` instance that's not associated
        with a :class:`.ConnectionPoolEntry`, such as if it were detached, the
        attribute returns a dictionary that is local to that
        :class:`.ConnectionPoolEntry`. Therefore the
        :attr:`.ManagesConnection.info` attribute will always provide a Python
        dictionary.

        .. seealso::

            :attr:`.ManagesConnection.record_info`


        rIrYs r.�infozManagesConnection.infos
��0"�#�#r-c��t��)a�Persistent info dictionary associated with this
        :class:`.ManagesConnection`.

        Unlike the :attr:`.ManagesConnection.info` dictionary, the lifespan
        of this dictionary is that of the :class:`.ConnectionPoolEntry`
        which owns it; therefore this dictionary will persist across
        reconnects and connection invalidation for a particular entry
        in the connection pool.

        For a :class:`.PoolProxiedConnection` instance that's not associated
        with a :class:`.ConnectionPoolEntry`, such as if it were detached, the
        attribute returns None. Contrast to the :attr:`.ManagesConnection.info`
        dictionary which is never None.


        .. seealso::

            :attr:`.ManagesConnection.info`

        rIrYs r.�record_infozManagesConnection.record_info,s
��,"�#�#r-Nc��t��)aOMark the managed connection as invalidated.

        :param e: an exception object indicating a reason for the invalidation.

        :param soft: if True, the connection isn't closed; instead, this
         connection will be recycled on next checkout.

        .. seealso::

            :ref:`pool_connection_invalidation`


        rI�r<r��softs   r.r�zManagesConnection.invalidateDs
�� "�#�#r-�rPr�rPzOptional[_InfoType]�NF�r�r�r�r%rPrQ)r&r'r(r)r*r+r�ro_memoized_propertyr�r�r�r,r-r.r�r��s}����I�/�/��(%�$��(
���$��$�2
���$��$�0?D�$�(�$�7;�$�	
�$r-r�c�.�eZdZdZdZedd��Zdd�Zy)rbaInterface for the object that maintains an individual database
    connection on behalf of a :class:`_pool.Pool` instance.

    The :class:`.ConnectionPoolEntry` object represents the long term
    maintainance of a particular connection for a pool, including expiring or
    invalidating that connection to have it replaced with a new one, which will
    continue to be maintained by that same :class:`.ConnectionPoolEntry`
    instance. Compared to :class:`.PoolProxiedConnection`, which is the
    short-term, per-checkout connection manager, this object lasts for the
    lifespan of a particular "slot" within a connection pool.

    The :class:`.ConnectionPoolEntry` object is mostly visible to public-facing
    API code when it is delivered to connection pool event hooks, such as
    :meth:`_events.PoolEvents.connect` and :meth:`_events.PoolEvents.checkout`.

    .. versionadded:: 2.0  :class:`.ConnectionPoolEntry` provides the public
       facing interface for the :class:`._ConnectionRecord` internal class.

    r,c��t��)z3Return True the connection is currently checked outrIrYs r.�in_usezConnectionPoolEntry.in_usens
��"�#�#r-c��t��)zAClose the DBAPI connection managed by this connection pool entry.rIrYs r.rCzConnectionPoolEntry.closetr�r-Nr�r�)r&r'r(r)r*r�r�rCr,r-r.rbrbWs%���(�I�
�$��$�
$r-rbc��eZdZUdZdZded<ded<ded<d	ed
<d$d%d�Zded
<ed&d��Zee	jdd�d'd���ZdZd	ed<e	jd(d��Ze	jd)d��Zed*d��Z	d$					d+d�Zd$d,d�Zed-d��Zed.d��Zd/d�Z	d0					d1d�Zd2d�Zd-d �Zdd!�d3d"�Zd/d#�Zy)4r�aMaintains a position in a connection pool which references a pooled
    connection.

    This is an internal object used by the :class:`_pool.Pool` implementation
    to provide context management to a DBAPI connection maintained by
    that :class:`_pool.Pool`.   The public facing interface for this class
    is described by the :class:`.ConnectionPoolEntry` class.  See that
    class for public API details.

    .. seealso::

        :class:`.ConnectionPoolEntry`

        :class:`.PoolProxiedConnection`

    )�__pool�	fairy_ref�finalize_callback�freshr�r=�__weakref__�__dict__z(Deque[Callable[[DBAPIConnection], None]]r�r%r��'Optional[weakref.ref[_ConnectionFairy]]r�rnr�c��d|_d|_d|_d|_||_|r|j�t
�|_y)NFr)r�r�r�r=�_ConnectionRecord__pool�_ConnectionRecord__connectrr�)r<�poolr�s   r.r�z_ConnectionRecord.__init__�s=����
������� $��������N�N��!&���r-r�r=c�z�|j�y|jjj|j�Sr:)r=r�rjrNrYs r.r�z#_ConnectionRecord.driver_connection�s7��� � �(���;�;�'�'�=�=��%�%��
r-�2.0zXThe _ConnectionRecord.connection attribute is deprecated; please use 'driver_connection'c��|jSr:�r=rYs r.rMz_ConnectionRecord.connection�����$�$�$r-r�_soft_invalidate_timec��iSr:r,rYs r.r�z_ConnectionRecord.info�����	r-c��iSr:r,rYs r.r�z_ConnectionRecord.record_info�rr-c�����trtt�j���n�j��	�j	�}�j��t�|���}tj|���fd��x�_
}�t|<�r�jj!d|�|S#t
$rB}t
j�5�j|d��ddd��#1swY�xYwd}~wwxYw)NF��_fairy_was_createdc�6��t�td��|�d��SdS)NF�r")�_finalize_fairy)�refrgr�ras ���r.r�z,_ConnectionRecord.checkout.<locals>.<lambda>�s1���#�.� ��#�t�S�$�e����	r-z#Connection %r checked out from pool)rrr�r��get_connectionr�r�safe_reraise�_checkin_failed�_should_log_debugr��weakrefrr��_strong_ref_connection_recordsr�r�)�clsr�r=�err�fairyrrgras `    @@r.�checkoutz_ConnectionRecord.checkout�s������(�$�,�,�.�9�C��,�,�.�C�	�"�1�1�3���%�%�'�� ��'7��d�C��%�k�k��
�	
�		
��
��/2�&�s�+���K�K���5�7G�
����3�	��"�"�$��#�#�C�E�#�B�%�
�	%�
��	�s/�B3�3	C>�<C9�C-�$	C9�-C6	�2C9�9C>c�L�|j|��|j|��y)N�r�r)r��checkin)r<rrs   r.rz!_ConnectionRecord._checkin_failed�s&��	
���#������1�	�	
r-c��|j�|rtjd|z�yd|_|j}|j}|j
r1|j
j
�}|�||�|j
r�1|jjr|jj||�|j|�y)NzDouble checkin attempted on %s)
r�r�warnr=r�r��poprerr�)r<rrMr��	finalizers     r.rz_ConnectionRecord.checkin�s����>�>�!�&8�
�I�I�6��=�>������*�*�
��{�{���$�$��.�.�2�2�4�I��%��*�%��$�$��=�=� � ��M�M�!�!�*�d�3����$�r-c��|jduSr:)r�rYs r.r�z_ConnectionRecord.in_uses���~�~�T�)�)r-c��|jSr:)r�rYs r.�last_connect_timez#_ConnectionRecord.last_connect_times���~�~�r-c�>�|j�|j�yyr:)r=�_ConnectionRecord__closerYs r.rCz_ConnectionRecord.closes��� � �,��L�L�N�-r-NFc�X�|j�y|r2|jjj|j||�n1|jjj	|j||�|�L|jj
j
d|rdnd|j|jj|�n5|jj
j
d|rdnd|j�|rtj�|_
y|jd��d|_y)Nz*%sInvalidate connection %r (reason: %s:%s)zSoft �z%sInvalidate connection %rTr�)r=r�re�soft_invalidater�r�r��	__class__r&r�rr"r�s   r.r�z_ConnectionRecord.invalidates���� � �(����K�K� � �0�0��%�%�t�Q�
�
�K�K� � �+�+�D�,A�,A�4��K��=��K�K���#�#�<���R��%�%����$�$��
�
�K�K���#�#�,���R��%�%�
��)-����D�&��L�L�4�L�(�$(�D�!r-c�p�d}|j�,|jj�|j��n%|jj
dkDrkt
j�|jz
|jj
kDr3|jjjd|j�d}n�|jj|jkDr3|jjjd|j�d}nK|j|jkDr2|jjjd|j�d}|r<|jd��|jj�|j�|j�J�|jS)NFr�z)Connection %r exceeded timeout; recyclingTz=Connection %r invalidated due to pool invalidation; recyclingzCConnection %r invalidated due to local soft invalidation; recyclingr�)r=r��clearr�r�rxr�r�r�rorr")r<rs  r.r
z _ConnectionRecord.get_connection4sT����� � �(��I�I�O�O���N�N���K�K� � �2�%��	�	��d�n�n�,�t�{�{�/C�/C�C��K�K���#�#�;��%�%�
��G�
�[�[�
)�
)�D�N�N�
:��K�K���#�#���%�%�
�
�G�
�
'�
'�$�.�.�
8��K�K���#�#���%�%�
�
�G���L�L�4�L�(��I�I�O�O���N�N���$�$�0�0�0��$�$�$r-c��|jduxs>|jj|jkDxs|j|jkDSr:)r=r�ror�rrYs r.�_is_hard_or_soft_invalidatedz._ConnectionRecord._is_hard_or_soft_invalidatedhsG���!�!�T�)�
=��{�{�+�+�d�n�n�<�
=��*�*�T�^�^�;�	
r-r�c�P�|jj�|jjjr0|jjj	|j
|�|j
�J�|jj
|j
|��d|_y)Nr�)r�r(r�rerCr=r�)r<r�s  r.�__closez_ConnectionRecord.__closeos������$�$�&��;�;���%�%��K�K� � �&�&�t�'<�'<�d�C��$�$�0�0�0����%�%��!�!�Y�	&�	
�!%��r-c���|j}d|_	tj�|_|j	|�x|_}|j
j
d|�d|_|jjrI|jjj|j�j|j|�|jjj|j�j|j|�y#t$rU}tj �5|j
j
d|�ddd�n#1swYnxYwYd}~yYd}~yd}~wwxYw)NzCreated new connection %rTzError on connect(): %s)r�r=r�r�rmr�r�r�re�
first_connect�
for_modify�exec_once_unless_exceptionr��_exec_w_sync_on_first_runr�rr)r<r�rMr�s    r.�	__connectz_ConnectionRecord.__connectys���{�{��!%���	E�!�Y�Y�[�D�N�15�1E�1E�d�1K�K�D�!�J��K�K���9�:�F��D�J��}�}�*�*��
�
�+�+�6�6��M�M��,�,�T�-B�-B�D�I�
�M�M�!�!�,�,��
�
�
�'�'��(=�(=�t�D���	?��"�"�$����!�!�":�A�>�%�$�$��$�$��	?�s0�AD�	E0�E+�/E�	E+�E	�E+�+E0)T)r�rdr�r%�rPr�)rPr�r�r�)r�rdrPr�)rr�rr%rPrQ)rr%rPrQr�)rPrnr�r�r�r[)r�r%rPrQ)r&r'r(r)r*r+r�r�r�r�
deprecatedrMrr�r�r��classmethodrrrr�r rCr�r
r*r"r�r,r-r.r�r�ys^���"	�I�@�?��K�6�6���	)�0�/�
������T�_�_�
�	)��
%���%�$%��5�$�	������
�������!��!�H>B�
� �
�6:�
�	
�
� �.�*��*������
?D�)�(�)�7;�)�	
�)�B2%�h
�,1�%�Er-r�c��|du}|r>|�J�tj|d�|�J�|j|ury|�J�|j}n+|r)tjt	j
|�d�|jj}|ri|duxs|}	|}
|jjxs|jj}|jjxr|jj}n
|du}	dx}
}d}|��|r|r|jjd|�	|s|�J�t||||�}|j|usJ�|j|||	|
��|	r_|r||_
|j�|rD|jj r|jj!|�|j#||��|	rB|r@|r>d
|�d|sdnd
�d�}|jj'|�t/j0|�	|r|j�|j3�|�d|_d|_~~~y#t$$rL}
|jj'dd��|r|j)|
�	�t+|
t,�s�Yd}
~
��d}
~
wwxYw#|	rD|rA|r>d
|�d|sdnd
�d�}|jj'|�t/j0|�wwwwxYw)acCleanup for a :class:`._ConnectionFairy` whether or not it's already
    been garbage collected.

    When using an async dialect no IO can happen here (without using
    a dedicated thread), since this is called outside the greenlet
    context and with an already running loop. In this case function
    will only log a message and raise a warning.
    NTFz$Connection %r being returned to poolr!r�z!Exception during reset or similarr�rzFThe garbage collector is trying to clean up non-checked-in connection z, which will be z*dropped, as it cannot be safely terminated�
terminatedz�.  Please ensure that SQLAlchemy pooled connections are returned to the pool explicitly, either by calling ``close()`` or by using appropriate context managers to manage their lifecycle.)rrr�r=rrrjrRrSr�r�r��_reset�_pool�detachre�close_detachedr�r�r�r�r�r�rrrr�)r=r�r�rrgr"r�
is_gc_cleanup�dont_restore_gcedr:�can_manipulate_connection�!can_close_or_terminate_connection�requires_terminate_for_closer��messages               r.rr�s;��(�t�O�M������&�*�*�3��5� �,�,�,��&�&�c�1���'�'�'�,�=�=��	�&�*�*�7�;�;�u�+=�t�D��
�
�.�.���"�d�*�;�m��(5�$5�!��
�
�&�&�&�E�$�-�-�*E�*E�	*�
�M�M�"�"�B�t�}�}�'B�'B�	%�
#�d�*��HL�L�!�$E�',�$��#����K�K���6�8H�
�9	#��(�4�4�4�(��$�%��	���)�)�-=�=�=�=��L�L��&;�%�6�	
�
��$�"&�E�K��L�L�N�4��}�}�3�3��
�
�4�4�5E�F��*�*�(�">�+���-�,=�1�1A�0D�E'� A�E�)�'�'�
'�����!�!�'�*��	�	�'�"��.�8�8�D��!�!�#�
��!%���#'�� ���
��O�	��K�K���3�d�
�
�!�!�,�,�q�,�1��a��+��,��
	���-�,=�1�1A�0D�E'� A�E�)�'�'�
'�����!�!�'�*��	�	�'�"�!->�-�v�s-�BH.�.	J�7AI>�9J�>J�J�AKz6Dict[weakref.ref[_ConnectionFairy], _ConnectionRecord]rc�x�eZdZdZdZejrdd�Zdd�Zdd�Z	e
d
d��Ze
d
d��Zdd�Z
dd	�Zy
)rOaA connection-like adapter for a :pep:`249` DBAPI connection, which
    includes additional methods specific to the :class:`.Pool` implementation.

    :class:`.PoolProxiedConnection` is the public-facing interface for the
    internal :class:`._ConnectionFairy` implementation object; users familiar
    with :class:`._ConnectionFairy` can consider this object to be equivalent.

    .. versionadded:: 2.0  :class:`.PoolProxiedConnection` provides the public-
       facing interface for the :class:`._ConnectionFairy` internal class.

    r,c��yr:r,rYs r.r5zPoolProxiedConnection.commit4s��#r-c��yr:r,rYs r.�cursorzPoolProxiedConnection.cursor6s��r-c��yr:r,rYs r.r6zPoolProxiedConnection.rollback8s��Cr-c��t��)zgReturn True if this :class:`.PoolProxiedConnection` still refers
        to an active DBAPI connection.rIrYs r.r�zPoolProxiedConnection.is_valid:�
��
"�#�#r-c��t��)zVReturn True if this :class:`.PoolProxiedConnection` is detached
        from its pool.rIrYs r.�is_detachedz!PoolProxiedConnection.is_detachedArHr-c��t��)aSeparate this connection from its Pool.

        This means that the connection will no longer be returned to the
        pool when closed, and will instead be literally closed.  The
        associated :class:`.ConnectionPoolEntry` is de-associated from this
        DBAPI connection.

        Note that any overall connection limiting constraints imposed by a
        Pool implementation may be violated after a detach, as the detached
        connection is removed from the pool's knowledge and control.

        rIrYs r.r:zPoolProxiedConnection.detachHs
��"�#�#r-c��t��)a$Release this connection back to the pool.

        The :meth:`.PoolProxiedConnection.close` method shadows the
        :pep:`249` ``.close()`` method, altering its behavior to instead
        :term:`release` the proxied connection back to the connection pool.

        Upon release to the pool, whether the connection stays "opened" and
        pooled in the Python process, versus actually closed out and removed
        from the Python process, is based on the pool implementation in use and
        its configuration and current state.

        rIrYs r.rCzPoolProxiedConnection.closeXr�r-Nr�)rPrr�)r&r'r(r)r*�typingrr5rEr6r�r�rJr:rCr,r-r.rOrO#sP��
��I�
���%�,�'�
�$��$��$��$�$� 
$r-rOc��eZdZUdZdZded<ded<				dd�Zedd��Zedd	��Z	edd
��Z
	d					dd�Zejdd
��Zdd�Zdd�Zy)�_AdhocProxiedConnectionadprovides the :class:`.PoolProxiedConnection` interface for cases where
    the DBAPI connection is not actually proxied.

    This is used by the engine internals to pass a consistent
    :class:`.PoolProxiedConnection` object to consuming dialects in response to
    pool events that may not always have the :class:`._ConnectionFairy`
    available.

    �r=r��	_is_validrr=rbr�c�.�||_||_d|_yr�rP)r<r=r�s   r.r�z _AdhocProxiedConnection.__init__xs��
!1���"3�����r-c�.�|jjSr:�r�r�rYs r.r�z)_AdhocProxiedConnection.driver_connection�s���&�&�8�8�8r-c��|jSr:rrYs r.rMz"_AdhocProxiedConnection.connection�s���$�$�$r-c��|jS)z�Implement is_valid state attribute.

        for the adhoc proxied connection it's assumed the connection is valid
        as there is no "invalidate" routine.

        �rQrYs r.r�z _AdhocProxiedConnection.is_valid�s���~�~�r-Nc��d|_yr�rWr�s   r.r�z"_AdhocProxiedConnection.invalidate�s����r-c�.�|jjSr:�r�r�rYs r.r�z#_AdhocProxiedConnection.record_info�s���&�&�2�2�2r-c�:�|jj|i|��Sr:�r=rE�r<�args�kwargss   r.rEz_AdhocProxiedConnection.cursor�s ��+�t�$�$�+�+�T�<�V�<�<r-c�.�t|j|�Sr:�r�r=�r<�keys  r.�__getattr__z#_AdhocProxiedConnection.__getattr__�����t�,�,�c�2�2r-)r=rr�rb)rPrr[r�r�r�r��r^rr_rrPr)rcrrPr)r&r'r(r)r*r+r�r�r�rMr�r�r�ro_non_memoized_propertyr�rErdr,r-r.rOrOhs����H�I�%�%�+�+��)��/���9��9��%��%�����?D��(��7;��	
��

�"�"�3�#�3�=�3r-rOc���eZdZUdZdZded<ded<ded<								d!d	�Zd
ed<ed"d��Zee	jd
d�d#d���Ze		d$							d%d��Z
d&d�Zd'd(d�Zd)d�Z										d*d�Zed+d��Zed,d��Zed,d��Ze	j*d-d��Ze	j.d.d��Z	d/					d0d�Zd1d�Zd2d�Zd)d�Zd)d�Zd'd3d �Zy)4r�a&Proxies a DBAPI connection and provides return-on-dereference
    support.

    This is an internal object used by the :class:`_pool.Pool` implementation
    to provide context management to a DBAPI connection delivered by
    that :class:`_pool.Pool`.   The public facing interface for this class
    is described by the :class:`.PoolProxiedConnection` class.  See that
    class for public API details.

    The name "fairy" is inspired by the fact that the
    :class:`._ConnectionFairy` object's lifespan is transitory, as it lasts
    only for the length of a specific DBAPI connection being checked out from
    the pool, and additionally that as a transparent proxy, it is mostly
    invisible.

    .. seealso::

        :class:`.PoolProxiedConnection`

        :class:`.ConnectionPoolEntry`


    )r=r��_echor9�_counterr�r�rdr�rr=rfric�J�||_d|_||_||_||_y)Nr)r9rjr=r�ri)r<r�r=r�rgs     r.r�z_ConnectionFairy.__init__�s)����
���
� 0���"3�����
r-�Optional[_ConnectionRecord]r�c�H�|j�y|jjSr:rTrYs r.r�z"_ConnectionFairy.driver_connection�s#���"�"�*���&�&�8�8�8r-r�zWThe _ConnectionFairy.connection attribute is deprecated; please use 'driver_connection'c��|jSr:rrYs r.rMz_ConnectionFairy.connection�rr-Nc�~�|s1tj|�}|�tj|�|_|j
�Jd��|j�Jd��|xjdz
c_|jjs|jr|jdk7r|Sd}|dkD�r:|j
j}d|j
_
	|jr�|s�|jr&|jjd|j�|jj|j�}|sx|jr&|jjd|j�t!j"��|jr&|jjd	|j�|jj|j|j
|�|S|jj)d�|j+�t!j8d��#t j$$�r#}|j&rL|jj)d
|�|j
j+|�|j-||d��nB|jj)d|j|�|j
j+|�	|j
j/�|_nY#t0$rM}t3j4�5|j
j7|d
��~ddd��#1swY�xYwd}~wwxYw|dz}Yd}~n`d}~wt0$rQ}	t3j4�5|j
}
|
�|
j7|	d
��~ddd��#1swY�xYwd}	~	wwxYw|dkDr�����)Nz,can't 'checkout' a detached connection fairyz0can't 'checkout' an invalidated connection fairyr1rrFzPool pre-ping on connection %sz;Pool pre-ping on connection %s failed, will invalidate poolz)Connection %s is fresh, skipping pre-pingzoDisconnection detected on checkout, invalidating all pooled connections prior to current timestamp (reason: %r)�r�zVDisconnection detected on checkout, invalidating individual connection %s (reason: %r)Trz+Reconnection attempts exhausted on checkoutzThis connection is closed)r�rrr�currentr�r=rjreryr�rir�r�rjrKr�InvalidatePoolError�DisconnectionError�invalidate_poolr�r�r�r
r�rrr�InvalidRequestError)rr��threadconnsr�attempts�connection_is_fresh�resultr�r�be_outerras           r.r�z_ConnectionFairy._checkout�sj���%�.�.�t�4�E��&�&-�k�k�%�&8��#�
�$�$�0�	:�9�	:�0�
�"�"�.�	>�=�	>�.�	���!����
�
�&�&�t�~�~�
�^�^�q�
 ��L�����l�"'�":�":�"@�"@��-2�E�$�$�*�S
��>�>�.� �;�;� �K�K�-�-� @� %� 6� 6��"&���!?�!?�!�2�2�"�� &�$�{�{� $��� 1� 1�%;�$)�$:�$:�!"�
#&�"9�"9�";�;�������)�)�G�!�2�2��
�
�
�&�&��*�*�E�,D�,D�e����r	
�����F�G�
�����%�%�&A�B�B��u�)�)�'
��$�$��K�K�$�$�9��	��,�,�7�7��:��$�$�U�A��$�>��K�K�$�$�M��.�.��	��,�,�7�7��:���0�0�?�?�A��*��%���*�*�,��0�0�@�@��/3�A��"�-��-�����"�A�
��� �
��&�&�(��2�2�C����+�+�$�/3�,���)��)���
��Q��l�sz�DH$�$N3�8BM�K3�2M�3	M	�<M�L8�/	M�8M�=M�M	�	M�N3�"N.�6#N"�	N.�"N+	�'N.�.N3c�D�tj|j|��S)N)r)r�r�r9rYs r.�_checkout_existingz#_ConnectionFairy._checkout_existingfs���)�)�$�*�*�D�)�A�Ar-c	�x�t|j|j|jd|j||��y)N)r"r)rr=r�r9ri)r<r"s  r.r�z_ConnectionFairy._checkinis3����!�!��#�#��J�J���J�J�"7��	
r-c�$�|j�yr:rprYs r.�_closez_ConnectionFairy._closets���
�
�r-c	��|jjr=|jj|j|jt	|||���|sy|j
tur�|r3|jru|jjd|j�y|jr&|jjd|j�|jj|�yy|j
turN|jr&|jjd|j�|jj|�yy)Nr!z.Connection %s reset, transaction already resetz Connection %s rollback-on-returnzConnection %s commit-on-return)re�resetr=r�r r{r2rir�r�rjr>r3r@)r<r�r"r#r$s     r.r8z_ConnectionFairy._resetws���=�=����M�M����%�%��'�'��*?�#1�!-��
���� � �N�2�$��:�:��K�K�%�%�H��-�-��
�:�:��K�K�%�%�:��-�-���
�
�)�)�$�/���
"�
"�l�
2��z�z����!�!�4��)�)��
�M�M�#�#�D�)�
3r-c�.�|jjSr:)r9r�rYs r.�_loggerz_ConnectionFairy._logger�s���z�z� � � r-c��|jduSr:rrYs r.r�z_ConnectionFairy.is_valid�s���$�$�D�0�0r-c��|jduSr:)r�rYs r.rJz_ConnectionFairy.is_detached�s���&�&�$�.�.r-c�J�|j�iS|jjSr:)r�r�rYs r.r�z_ConnectionFairy.info�s%���"�"�*��I��*�*�/�/�/r-c�H�|j�y|jjSr:rZrYs r.r�z_ConnectionFairy.record_info�s#���"�"�*���*�*�6�6�6r-c���|j�tjd�y|jr|jj	||��|sd|_|j�yy)Nz.Can't invalidate an already-closed connection.)r�r�)r=rrr�r�r�r�s   r.r�z_ConnectionFairy.invalidate�s_��� � �(��I�I�F�G���"�"��#�#�.�.���.�>��%)�D�!�
�M�M�O�
r-c�V�|j�J�|jj|i|��Sr:r\r]s   r.rEz_ConnectionFairy.cursor�s2���$�$�0�0�0�+�t�$�$�+�+�T�<�V�<�<r-c�.�t|j|�Sr:rarbs  r.rdz_ConnectionFairy.__getattr__�rer-c��|j��|j}d|_d|_|jj	|j�|j
j
�|_d|_|jjjr1|jjj|j|�yyyr:)	r�r�r=r9r�r��copyrer:r`s  r.r:z_ConnectionFairy.detach�s����"�"�.��)�)�C� �C�M�#'�C� ��J�J�&�&�t�'>�'>�?��	�	���(�D�I�&*�D�#��z�z�"�"�)�)��
�
�#�#�*�*�4�+@�+@�#�F�*�/r-c�n�|xjdzc_|jdk(r|j�yy)Nr1r�rjr�rYs r.rCz_ConnectionFairy.close�s*���
�
���
��=�=�A���M�M�O�r-c�r�|xjdzc_|jdk(r|j|��yy)Nr1rr
r�)r<�transaction_resets  r.�_close_specialz_ConnectionFairy._close_special�s0���
�
���
��=�=�A���M�M�0A�M�B�r-)r�rdr=rr�r�rgrfr3r[)NN)r�rdrvzOptional[threading.local]r�Optional[_ConnectionFairy]rPr�)rPr�)F)r"r%rPrQr�)
r�rdr"r%r#r%r$r%rPrQ)rPzlog._IdentifiedLoggerTyper�r�r�r�r�rf)rcr�rPr)r�r%rPrQ)r&r'r(r)r*r+r�r�r�rr4rMr5r�r|r�rr8r�r�rJr�r�rgr�r�rErdr:rCr�r,r-r.r�r��s����0�I��J�%�%������*��-�	�
 ��4�3�
�9��9�
��T�_�_�
�	)��
%���%��26�,0�	{C��{C�/�{C�*�	{C�

�{C��{C�zB�	
��)*��)*� $�)*��	)*�
�)*�
�
)*�V�!��!��1��1��/��/�
���0��0�
�"�"�7�#�7�?D��(��7;��	
�� =�3�G�"�
Cr-r�)FN)r=r�r�rlr�rdrr�rgzOptional[log._EchoFlagType]r"r%rr�rPrQ)?r)�
__future__r�collectionsr�dataclasses�enumr�	threadingr�rMrrrr	r
rrr
rrrr$rrrr�util.typingrr�engine.interfacesrrrrrr�sql._typingr�	dataclassr r0r��listr2r3r4r8rUrWr^�
Identified�EventTargetrdr�rbr�rrr+rOrOr�r,r-r.�<module>r�s����#������
��������� �������!�"��3�/�+�'�'�"�'�����d�#�)�)�$�)�X������3�4�6���,0�
�+;�(���j� � �F���/�X�/�I��I�{$�3�>�>�5�,�,�{$�|	y$�y$�x$�+�$�DZE�+�ZE�J	#(�(,�A�/�A�2�A��A�
�	A�&�A� �A�&�A�
�A�T��!��
B$�-�B$�J83�3�83�vIC�,�ICr-

if you don't want to be vaporized in a nuclear explosion, i simply have to become nuclear myself… i am atomic