Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
base.cpython-313.pyc501 linesDownload Raw Back to __pycache__
1�

2��j`���V�%SrSSKJr SSKJr SSKrSSKJr SSKrSSK	r	SSK3r4SSK5Jr SSK6Jr SSK7J
r
 SS	K8Jr SS9K10Jr SSK11Jr SSK12Jr SS
K13Jr SSK14Jr SSK15Jr SSKrSSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr \(a*SSKJ r  SSKJ!r! SSKJ"r" SSKJ#r# SSKJ$r$ SSKJ%r% SSK&J'r' \RP"SS 9"S!S"55r)"S#S$\5r*\\*\S%4r+\,"\*5ur-r.r/"S&S'5r0"S(S)\05r1"S*S+\5r2"S,S-\5r3"S.S/\Rh\Rj5r6"S0S15r7"S2S3\75r8"S4S5\85r9S?S@S6jjr:0r;S7\<S8'"S9S:\75r="S;S<\=5r>"S=S>\=5r?g)Az%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)�Self)�DBAPIConnection)�DBAPICursor)�Dialect)�_DispatchCommon)�_ListenerFnType)�16dispatcher)�	_InfoTypeT)�frozenc�@�\rSrSr%SrSrS\S'S\S'S\S'Srg	)17�PoolResetState�1z�describes the state of a DBAPI connection as it is being passed to18the :meth:`.PoolEvents.reset` connection pool event.19 20.. versionadded:: 2.0.0b321 22��transaction_was_reset�terminate_only�asyncio_safe�boolr$r%r&�N)�__name__�23__module__�__qualname__�__firstlineno__�__doc__�	__slots__�__annotations__�__static_attributes__r(��ZD:\code\apps\devtools\python\user_packages\Python313\site-packages\sqlalchemy/pool/base.pyr!r!1s4���L�I���24���	���r1r!c�$�\rSrSrSrSrSrSrSrg)�25ResetStyle�^z1Describe options for "reset on return" behaviors.r�rr(N)	r)r*r+r,r-�reset_rollback�reset_commit�26reset_noner0r(r1r2r4r4^s��;��N��L��Jr1r4)TNF�commit�rollbackc�\�\rSrSrSrSrSrSSjrSSjrS
Sjr	S
Sjr27SSjrSS	jrS28r
g)�_ConnDialect�mz�partial implementation of :class:`.Dialect`29which provides DBAPI connection methods.30 31When a :class:`_pool.Pool` is combined with an :class:`_engine.Engine`,32the :class:`_engine.Engine` replaces this with its own33:class:`.Dialect`.34 35Fc�$�UR5 g�N)r;��self�dbapi_connections  r2�do_rollback�_ConnDialect.do_rollbackzs���!�!�#r1c�$�UR5 gr@)r:rAs  r2�	do_commit�_ConnDialect.do_commit}s�����!r1c�$�UR5 gr@��closerAs  r2�do_terminate�_ConnDialect.do_terminate������� r1c�$�UR5 gr@rJrAs  r2�do_close�_ConnDialect.do_close�rNr1c��[S5e)NzJThe ping feature requires that a dialect is passed to the connection pool.��NotImplementedErrorrAs  r2�_do_ping_w_event�_ConnDialect._do_ping_w_event�s��!�
-�36�	37r1c��U$r@r()rB�38connections  r2�get_driver_connection�"_ConnDialect.get_driver_connection�s���r1r(N)rC�PoolProxiedConnection�return�None)rCrr\r])rCrr\r')rXrr\r)r)r*r+r,r-�is_async�
has_terminaterDrGrLrPrUrYr0r(r1r2r=r=ms1����H��M�$�"�!�!�39�r1r=c��\rSrSrSrSrg)�_AsyncConnDialect�Tr(N)r)r*r+r,r^r0r(r1r2rara�s���Hr1rac��\rSrSrSSjrSrg)�_CreatorFnType�c��gr@r(�rBs r2�__call__�_CreatorFnType.__call__�s��3r1r(N�r\r�r)r*r+r,rhr0r(r1r2rdrd�s��.r1rdc��\rSrSrSSjrSrg)�_CreatorWRecFnType�c��gr@r(�rB�recs  r2rh�_CreatorWRecFnType.__call__�s��Sr1r(N)rq�ConnectionPoolEntryr\rrkr(r1r2rmrm�s��Hr1rmc���\rSrSr%SrS\S'S\S'S\S'\"5rS	\S40'S\S'S
\S'S\S'S%S&Sjjr\	RS'Sj5r\S(Sj5r
\
RS)Sj5r
\
RS*Sj5r
S+SjrSS.S,SjjrS-SjrS.S/SjjrS0SjrS*SjrS1SjrS2S jrS-S!jrS2S"jrS3S#jrS$rg)4�Pool�z)Abstract base class for connection pools.zdispatcher[Pool]�dispatch�log._EchoFlagType�echo�
Optional[str]�_orig_logging_namezUnion[_ConnDialect, Dialect]�_dialect�)Union[_CreatorFnType, _CreatorWRecFnType]�_creator_argrm�_invoke_creator�float�_invalidate_timeNFc41	���U(aU=UlUlOSUl[R"XS9 XlX lSUlX�l[R"U[RSS/[R/SQ[RS/0S5UlX0lU	(aUR R#U	S	S429 U(aXplU(a#UHup�[&R("XU435 M gg)a�44Construct a Pool.45 46:param creator: a callable function that returns a DB-API47  connection object.  The function will be called with48  parameters.49 50:param recycle: If set to a value other than -1, number of51  seconds between connection recycling, which means upon52  checkout, if this timeout is surpassed the connection will be53  closed and replaced with a newly opened connection. Defaults to -1.54 55:param logging_name:  String identifier which will be used within56  the "name" field of logging records generated within the57  "sqlalchemy.pool" logger. Defaults to a hexstring of the object's58  id.59 60:param echo: if True, the connection pool will log61 informational output such as when connections are invalidated62 as well as when connections are recycled to the default log handler,63 which defaults to ``sys.stdout`` for output..   If set to the string64 ``"debug"``, the logging will include pool checkouts and checkins.65 66 The :paramref:`_pool.Pool.echo` parameter can also be set from the67 :func:`_sa.create_engine` call by using the68 :paramref:`_sa.create_engine.echo_pool` parameter.69 70 .. seealso::71 72     :ref:`dbengine_logging` - further detail on how to configure73     logging.74 75:param reset_on_return: Determine steps to take on76 connections as they are returned to the pool, which were77 not otherwise handled by a :class:`_engine.Connection`.78 Available from :func:`_sa.create_engine` via the79 :paramref:`_sa.create_engine.pool_reset_on_return` parameter.80 81 :paramref:`_pool.Pool.reset_on_return` can have any of these values:82 83 * ``"rollback"`` - call rollback() on the connection,84   to release locks and transaction resources.85   This is the default value.  The vast majority86   of use cases should leave this value set.87 * ``"commit"`` - call commit() on the connection,88   to release locks and transaction resources.89   A commit here may be desirable for databases that90   cache query plans if a commit is emitted,91   such as Microsoft SQL Server.  However, this92   value is more dangerous than 'rollback' because93   any data changes present on the transaction94   are committed unconditionally.95 * ``None`` - don't do anything on the connection.96   This setting may be appropriate if the database / DBAPI97   works in pure "autocommit" mode at all times, or if98   a custom reset handler is established using the99   :meth:`.PoolEvents.reset` event handler.100 101 * ``True`` - same as 'rollback', this is here for102   backwards compatibility.103 * ``False`` - same as None, this is here for104   backwards compatibility.105 106 For further customization of reset on return, the107 :meth:`.PoolEvents.reset` event hook may be used which can perform108 any connection activity desired on reset.109 110 .. seealso::111 112    :ref:`pool_reset_on_return`113 114    :meth:`.PoolEvents.reset`115 116:param events: a list of 2-tuples, each of the form117 ``(callable, target)`` which will be passed to :func:`.event.listen`118 upon construction.   Provided here so that event listeners119 can be assigned via :func:`_sa.create_engine` before dialect-level120 listeners are applied.121 122:param dialect: a :class:`.Dialect` that will handle the job123 of calling rollback(), close(), or commit() on DBAPI connections.124 If omitted, a built-in "stub" dialect is used.   Applications that125 make use of :func:`_sa.create_engine` should not use this parameter126 as it is handled by the engine creation strategy.127 128:param pre_ping: if True, the pool will emit a "ping" (typically129 "SELECT 1", but is dialect-specific) on the connection130 upon checkout, to test if the connection is alive or not.   If not,131 the connection is transparently re-connected and upon success, all132 other pooled connections established prior to that timestamp are133 invalidated.     Requires that a dialect is passed as well to134 interpret the disconnection error.135 136 .. versionadded:: 1.2137 138N)�echoflagrr;T)�noneNFr:�reset_on_returnF)�only_propagate)�logging_namer{r�instance_logger�_creator�_recycler��	_pre_pingr�parse_user_argument_for_enumr4r7r9r8�_reset_on_returnryrw�_updater|r�listen)rB�creator�recycleryr�r��events�dialect�pre_ping�	_dispatch�fn�targets            r2�__init__�
Pool.__init__�s���X�:F�F�D��� 7�&*�D�#����D�0��
��
� !���!�� $� A� A���)�)�J��+=��%�%�'<��'�'�(��
�139
�!140����	���M�M�!�!�)�E�!�B��#�M��$�141�����T�2�.�%�r1c�.�URR$r@)r|r^rgs r2�_is_asyncio�Pool._is_asyncio2s���}�}�%�%�%r1c��UR$r@)r~rgs r2r��
Pool._creator6s��� � � r1c�<�XlURU5Ulgr@)r~�_should_wrap_creatorr)rBr�s  r2r�r�:s��$�� $�8�8��A��r1c��U?U?gr@)r~rrgs r2r�r�Ds��
��� r1c�^�[R"URSS9nURb[UR5nOSn[US5U-142nUSUS4S/S4:Xa[	[U5$US:Xa[	[U5$[	[143U5mU4S	j$![a [	[144U5mU4Sjs$f=f)145z\Detect if creator accepts a single argument, or is sent146as a legacy style no-arg function.147 148T)�no_selfc�>�T"5$r@r(�rq�149creator_fns �r2�<lambda>�+Pool._should_wrap_creator.<locals>.<lambda>V����z�|r1r��connection_recordr@r6c�>�T"5$r@r(r�s �r2r�r�ir�r1)	r�get_callable_argspecr��	TypeErrorrrd�defaults�lenrm)rBr��argspec�	defaulted�positionalsr�s     @r2r��Pool._should_wrap_creatorJs����	,��/�/��
�
�t�L�G�150���'��G�,�,�-�I��I��'�!�*�o�	�1��
�A�J���151�#�)<�(=�w�'G�G��*�G�4�4�
�A�
��*�G�4�4��n�g�6�J�+�+��+�	,��n�g�6�J�+�+�	,�s�B%�% C�C��	terminatec�x�URRSU(aSOSU5 U(aURRU5 gURR	U5 g![152aHnURR
SU(aSOSS3USS	9 [U[5(deSnAgSnAff=f)153Nz%s connection %rzHard-closing�Closingz154Exception �terminating�closingz connection %rT��exc_info)	�logger�debugr|rLrP�
BaseException�error�155isinstance�	Exception)rBrXr��es    r2�_close_connection�Pool._close_connectionks���	
������'�N�Y��	156�157
	���
�
�*�*�:�6��
�
�&�&�z�2���	��K�K����i�]�Y�G�H �!���	
�
��a��+�+��,��	�s�"A'�A'�'158B9�1>B4�4B9c��[U5$)z6Called by subclasses to create a new ConnectionRecord.)�_ConnectionRecordrgs r2�_create_connection�Pool._create_connection�s��!��&�&r1c���[USS5nU(aURUR:a[R"5UlU(a%[USS5(aUR	U5 ggg)abMark all connections established within the generation159of the given connection as invalidated.160 161If this pool's last invalidate time is before when the given162connection was created, update the timestamp til now.  Otherwise,163no action is performed.164 165Connections with a start time prior to this pool's invalidation166time will be recycled upon next checkout.167�_connection_recordN�is_validF)�getattrr��	starttime�time�168invalidate)rBrX�	exception�_checkinrqs     r2�_invalidate�Pool._invalidate�s[�� �j�"6��=���d�+�+�c�m�m�;�$(�I�I�K�D�!���169�J��>�>��!�!�)�,�?�8r1c��[5e)z�Return a new :class:`_pool.Pool`, of the same class as this one170and configured with identical creation arguments.171 172This method is used in conjunction with :meth:`dispose`173to close out an entire :class:`_pool.Pool` and create a new one in174its place.175 176rSrgs r2�recreate�
Pool.recreate�s
��"�#�#r1c��[5e)z�Dispose of this pool.177 178This method leaves the possibility of checked-out connections179remaining open, as it only affects connections that are180idle in the pool.181 182.. seealso::183 184    :meth:`Pool.recreate`185 186rSrgs r2�dispose�Pool.dispose��
��"�#�#r1c�,�[RU5$)z�Return a DBAPI connection from the pool.187 188The connection is instrumented such that when its189``close()`` method is called, the connection will be returned to190the pool.191 192)�_ConnectionFairy�	_checkoutrgs r2�connect�Pool.connect�s�� �)�)�$�/�/r1c�&�URU5 g)z�Given a _ConnectionRecord, return it to the :class:`_pool.Pool`.193 194This method is called when an instrumented DBAPI connection195has its ``close()`` method called.196 197N)�_do_return_conn�rB�records  r2�_return_conn�Pool._return_conn�s��	
���V�$r1c��[5e)z7Implementation for :meth:`get`, supplied by subclasses.rSrgs r2�_do_get�Pool._do_get��
��"�#�#r1c��[5e)z?Implementation for :meth:`return_conn`, supplied by subclasses.rSr�s  r2r��Pool._do_return_conn�r�r1c��[5e)z6Returns a brief description of the state of this pool.rSrgs r2�status�Pool.status����!�#�#r1)r�r~r|r�rr{r�r�r�ryr�)�����NNTNNFN)r�r}r��intryrxr�rzr��_ResetStyleArgTyper�z+Optional[List[Tuple[_ListenerFnType, str]]]r�z&Optional[Union[_ConnDialect, Dialect]]r�r'r�zOptional[_DispatchCommon[Pool]]�r\r')r\r})r�r}r\r]�r\r])r�r}r\rm)rXrr�r'r\r])r\rs�NT)rXr[r��Optional[BaseException]r�r'r\r])r\ru)r\r[)r�rsr\r])r\�str)r)r*r+r,r-r/r=r|r�r�hybridpropertyr��propertyr��setter�deleterr�r�r�r�r�r�r�r�r�r�r�r0r(r1r2ruru�s���3���198��%�%�-9�^�H�*�;�;�;�'�'���199�"&�&*�.2�>B�:>��59�H/�:�H/��H/� �	H/�200$�H/�,�
H/�<�H/�8�H/��H/�3�H/�T201���&��&��!��!��_�_�B�@�B�	
�B��B����!��!�202,�@�,�	�,�DAF��)��9=��	
��.'�.2��	-�)�-�+�-��	-�203204�-�,205$�
$�0�%�$�206$�207$r1ruc��\rSrSr%SrSrS\S'S\S'\RSSj5r	\RS
S	j5r208SSSjjrSrg209)�ManagesConnectioni�aCommon base for the two connection-management interfaces210:class:`.PoolProxiedConnection` and :class:`.ConnectionPoolEntry`.211 212These two objects are typically exposed in the public facing API213via the connection pool event hooks, documented at :class:`.PoolEvents`.214 215.. versionadded:: 2.0216 217r(�Optional[DBAPIConnection]rC�
Optional[Any]�driver_connectionc��[5e)a Info dictionary associated with the underlying DBAPI connection218referred to by this :class:`.ManagesConnection` instance, allowing219user-defined data to be associated with the connection.220 221The data in this dictionary is persistent for the lifespan222of the DBAPI connection itself, including across pool checkins223and checkouts.  When the connection is invalidated224and replaced with a new one, this dictionary is cleared.225 226For a :class:`.PoolProxiedConnection` instance that's not associated227with a :class:`.ConnectionPoolEntry`, such as if it were detached, the228attribute returns a dictionary that is local to that229:class:`.ConnectionPoolEntry`. Therefore the230:attr:`.ManagesConnection.info` attribute will always provide a Python231dictionary.232 233.. seealso::234 235    :attr:`.ManagesConnection.record_info`236 237 238rSrgs r2�info�ManagesConnection.infos
��0"�#�#r1c��[5e)a�Persistent info dictionary associated with this239:class:`.ManagesConnection`.240 241Unlike the :attr:`.ManagesConnection.info` dictionary, the lifespan242of this dictionary is that of the :class:`.ConnectionPoolEntry`243which owns it; therefore this dictionary will persist across244reconnects and connection invalidation for a particular entry245in the connection pool.246 247For a :class:`.PoolProxiedConnection` instance that's not associated248with a :class:`.ConnectionPoolEntry`, such as if it were detached, the249attribute returns None. Contrast to the :attr:`.ManagesConnection.info`250dictionary which is never None.251 252 253.. seealso::254 255    :attr:`.ManagesConnection.info`256 257rSrgs r2�record_info�ManagesConnection.record_info+s
��,"�#�#r1Nc��[5e)aMark the managed connection as invalidated.258 259:param e: an exception object indicating a reason for the invalidation.260 261:param soft: if True, the connection isn't closed; instead, this262 connection will be recycled on next checkout.263 264.. seealso::265 266    :ref:`pool_connection_invalidation`267 268 269rS�rBr��softs   r2r��ManagesConnection.invalidateCs
�� "�#�#r1�r\r�r\zOptional[_InfoType]�NF�r�r�r270r'r\r])
r)r*r+r,r-r.r/r�ro_memoized_propertyrrr�r0r(r1r2r�r��s�����I�/�/��(%�$��(271���$��$�2272���$��$�0?D�$�(�$�7;�$�	
�$�$r1r�c�:�\rSrSrSrSr\SSj5rSSjrSr	g)	rsiVa�Interface for the object that maintains an individual database273connection on behalf of a :class:`_pool.Pool` instance.274 275The :class:`.ConnectionPoolEntry` object represents the long term276maintenance of a particular connection for a pool, including expiring or277invalidating that connection to have it replaced with a new one, which will278continue to be maintained by that same :class:`.ConnectionPoolEntry`279instance. Compared to :class:`.PoolProxiedConnection`, which is the280short-term, per-checkout connection manager, this object lasts for the281lifespan of a particular "slot" within a connection pool.282 283The :class:`.ConnectionPoolEntry` object is mostly visible to public-facing284API code when it is delivered to connection pool event hooks, such as285:meth:`_events.PoolEvents.connect` and :meth:`_events.PoolEvents.checkout`.286 287.. versionadded:: 2.0  :class:`.ConnectionPoolEntry` provides the public288   facing interface for the :class:`._ConnectionRecord` internal class.289 290r(c��[5e)z3Return True the connection is currently checked outrSrgs r2�in_use�ConnectionPoolEntry.in_usems
��"�#�#r1c��[5e)zAClose the DBAPI connection managed by this connection pool entry.rSrgs r2rK�ConnectionPoolEntry.closesr�r1Nr�r�)291r)r*r+r,r-r.r�rrKr0r(r1r2rsrsVs%���(�I�
�$��$�292$r1rsc���\rSrSr%SrSrS\S'S\S'S\S	'S293\S'S&S'SjjrS
\S'\S(Sj5r	\\294R"SS5S)Sj55rSr
S295\S'\296RS*Sj5r\297RS+Sj5r\S,Sj5rS&S-SjjrS&S.Sjjr\S/Sj5r\S0Sj5rS1SjrS2S3SjjrS4S jrS/S!jrSS".S5S#jjrS1S$jrS%rg)6r�ixa�Maintains a position in a connection pool which references a pooled298connection.299 300This is an internal object used by the :class:`_pool.Pool` implementation301to provide context management to a DBAPI connection maintained by302that :class:`_pool.Pool`.   The public facing interface for this class303is described by the :class:`.ConnectionPoolEntry` class.  See that304class for public API details.305 306.. seealso::307 308    :class:`.ConnectionPoolEntry`309 310    :class:`.PoolProxiedConnection`311 312)�__pool�	fairy_ref�finalize_callback�freshr�rC�__weakref__�__dict__z(Deque[Callable[[DBAPIConnection], None]]rr'r�'Optional[weakref.ref[_ConnectionFairy]]rr�r�c��SUlSUlSUlSUlXlU(aUR5 [
5Ulg)NFr)rrr�rC�_ConnectionRecord__pool�_ConnectionRecord__connectrr)rB�poolr�s   r2r��_ConnectionRecord.__init__�s;����313������� $�������N�N��!&���r1r�rCc�|�URcgURRRUR5$r@)rCr r|rYrgs r2r�#_ConnectionRecord.driver_connection�s7��� � �(���;�;�'�'�=�=��%�%��
r1�2.0zXThe _ConnectionRecord.connection attribute is deprecated; please use 'driver_connection'c��UR$r@�rCrgs r2rX�_ConnectionRecord.connection�����$�$�$r1r�_soft_invalidate_timec��0$r@r(rgs r2r�_ConnectionRecord.info�����	r1c��0$r@r(rgs r2r�_ConnectionRecord.record_info�r.r1c�"^^^�[(a[[TR55mOTR5mTR	5nTR5m[TUTT5n[R"UUUU4Sj5=Tl
nT[U'T(aTRR!SU5 U$![314aEn[R"5 TRUSS9 SSS5 e!,(df   e=fSnAff=f)NF��_fairy_was_createdc	�2>�[b[STTUTSS9$S$)NF�r$)�_finalize_fairy)�refryr"rqs ���r2r��,_ConnectionRecord.checkout.<locals>.<lambda>�s1���#�.� ��#�t�S�$�e����	r1z#Connection %r checked out from pool)rrr�r��get_connectionr�r�safe_reraise�_checkin_failed�_should_log_debugr��weakrefr7r�_strong_ref_connection_recordsr�r�)�clsr"rC�err�fairyr7ryrqs `    @@r2�checkout�_ConnectionRecord.checkout�s�����=��(�$�,�,�.�9�C��,�,�.�C�	�"�1�1�3���%�%�'�� ��'7��d�C��%�k�k��
�	315�		316��
��/2�&�s�+���K�K���5�7G�
����3�	��"�"�$��#�#�C�E�#�B�%�
�	%�$�
��	�s/�B?�?317D�	D	�C8�/	D	�8318D	�D	�	Dc�@�URUS9 URUS9 g)N�r�r2)r��checkin)rBr@r3s   r2r;�!_ConnectionRecord._checkin_failed�s&��	
���#������1�	�	319r1c��URc!U(a[R"SU-5 gSUlURnURnUR320(a8UR321R
5nUbU"U5 UR322(aM8URR(aURRX 5 URU5 g)NzDouble checkin attempted on %s)323rr�warnrCr r�poprwrFr�)rBr3rXr"�	finalizers     r2rF�_ConnectionRecord.checkin�s����>�>�!�&8�
�I�I�6��=�>������*�*�324��{�{���$�$��.�.�2�2�4�I��%��*�%��$�$�$��=�=� � ��M�M�!�!�*�3����$�r1c��URSL$r@)rrgs r2r�_ConnectionRecord.in_uses���~�~�T�)�)r1c��UR$r@)r�rgs r2�last_connect_time�#_ConnectionRecord.last_connect_time325s���~�~�r1c�@�URbUR5 ggr@)rC�_ConnectionRecord__closergs r2rK�_ConnectionRecord.closes��� � �,��L�L�N�-r1NFc�|�URcgU(a1URRRURX5 O0URRR	URX5 UbQURR326R
SU(aSOSURURRU5 O:URR327R
SU(aSOSUR5 U(a[R"5Ul328gURSS9 SUlg)Nz*%sInvalidate connection %r (reason: %s:%s)zSoft �z%sInvalidate connection %rTr�)rCr rw�soft_invalidater�r�r�	__class__r)r�r+rSr	s   r2r��_ConnectionRecord.invalidates���� � �(����K�K� � �0�0��%�%�t�
�
�K�K� � �+�+�D�,A�,A�4�K��=��K�K���#�#�<���R��%�%����$�$��
�
�K�K���#�#�,���R��%�%�
��)-����D�&��L�L�4�L�(�$(�D�!r1c��SnURc,URR5 UR5 GO*URR329S:�am[R"5UR-330URR331:�a3URRRSUR5 SnO�URRUR:�a3URRRSUR5 SnOLURUR:�a2URRRSUR5 SnU(a9URSS9 URR5 UR5 URceUR$)NFr�z)Connection %r exceeded timeout; recyclingTz=Connection %r invalidated due to pool invalidation; recyclingzCConnection %r invalidated due to local soft invalidation; recyclingr�)rCr�clearr!r r�r�r�r�r�r+rS)rBr�s  r2r9� _ConnectionRecord.get_connection3sT����� � �(��I�I�O�O���N�N���K�K� � �2�%��	�	��d�n�n�,�t�{�{�/C�/C�C��K�K���#�#�;��%�%�
��G�
�[�[�
)�
)�D�N�N�
:��K�K���#�#���%�%�
�332�G�
�
'�
'�$�.�.�
8��K�K���#�#���%�%�
�333�G���L�L�4�L�(��I�I�O�O���N�N���$�$�0�0�0��$�$�$r1c��URSL=(dC URRUR:�=(d URUR:�$r@)rCr r�r�r+rgs r2�_is_hard_or_soft_invalidated�._ConnectionRecord._is_hard_or_soft_invalidatedgsG���!�!�T�)�
=��{�{�+�+�d�n�n�<�
=��*�*�T�^�^�;�	334r1r�c�V�URR5 URRR(a0URRR	UR335U5 UR336ceURR
UR337US9 SUlg)Nr�)rr[r rwrKrCr�)rBr�s  r2�__close�_ConnectionRecord.__closens������$�$�&��;�;���%�%��K�K� � �&�&�t�'<�'<�d�C��$�$�0�0�0����%�%��!�!�Y�	&�	338�!%��r1c���URnSUl[R"5UlUR	U5=UlnUR339R
SU5 SUlURR(aIURRRUR5RURU5 URRRUR5RURU5 g![aYn[R "5 UR340R
SU5 SSS5 SnAg!,(df   SnAg=fSnAff=f)NzCreated new connection %rTzError on connect(): %s)r rCr�r�rr�r�rrw�
first_connect�341for_modify�exec_once_unless_exceptionr��_exec_w_sync_on_first_runr�rr:)rBr"rXr�s    r2�	__connect�_ConnectionRecord.__connectxs���{�{��!%���	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�>�%�$�$�$��	?�s6�AD�342E;�"E6�7E!�E6�!343E3	�+E6�3E6�6E;)rr+rCrrrr�)T)r"rur�r'�r\r)r\r�rr
)r"rur\r�)r@r�r3r'r\r])r3r'r\r]r�)r\r�r�rrrj)r�r'r\r])r)r*r+r,r-r.r/r�r�rr�344deprecatedrXr+rrr�classmethodrBr;rFrrPrKr�r9r^rSr!r0r(r1r2r�r�xs\���"	�I�@�?��K�6�6���	)�0�/�
�����	�_�_�
�	)��345%���%�$%��5�$�	������346�������!��!�H>B�347� �348�6:�349�	
�350� �.�*��*������351?D�)�(�)�7;�)�	
�)�B2%�h352�,1�%�Er1r�c��USLnU(aBUce[RUS5 UceURULagUbeURnO1U(a*[R[R353"U5S5 URRnU(a�USL=(d Un	U(+n354URR(+=(d URRnURR=(a URRnO	USLn	S=p�SnUGb2U(a#U(aURRSU5 U(dUce[UUUU5nURULdeURUUU	U355S9 U	(ajU(aX&l
UR5 U(aFURR (aURR!U5 UR#UUS9 U	(aRU(aKU(aDS356U<SU(dSOS
S3nURR'U5 [.R0"U5 U(aURbUR35 UbSUlSUlAAAg![$aPn
URR'SSS9 U(aUR)U
S	9 [+U
[,5(deSn
A
N�Sn
A
ff=f!U	(aUU(aMU(aES357U<SU(dSOS
S3nURR'U5 [.R0"U5 ffff=f)aKCleanup for a :class:`._ConnectionFairy` whether or not it's already358been garbage collected.359 360When using an async dialect no IO can happen here (without using361a dedicated thread), since this is called outside the greenlet362context and with an already running loop. In this case function363will only log a message and raise a warning.364NTFz$Connection %r being returned to poolr#r�z!Exception during reset or similarr�rEzFThe garbage collector is trying to clean up non-checked-in connection z, which will be z*dropped, as it cannot be safely terminated�365terminatedz�.  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.)r>rJrrCr=r7r|r^r_r�r�r��_reset�_pool�detachrw�close_detachedr�r�r�r�r�r�rrIrFr�)rCr�r"r7ryr$rA�
is_gc_cleanup�dont_restore_gcedrq�can_manipulate_connection�!can_close_or_terminate_connection�requires_terminate_for_closer��messages               r2r6r6�s9��(�t�O�M������&�*�*�3��5� �,�,�,��&�&�c�1���'�'�'�,�=�=��	�&�*�*�7�;�;�u�+=�t�D��
�
�.�.���"�d�*�;�m��(5�$5�!��
�
�&�&�&�E�$�-�-�*E�*E�	*�
�M�M�"�"�B�t�}�}�'B�'B�	%�366#�d�*��HL�L�!�',�$��#����K�K���6�8H�
�9	#��(�4�4�4�(��$�%��	���)�)�-=�=�=�=��L�L��&;�%�6�	
�
��$�"&�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-�B.J�367K.�AK)�$K1�)K.�.K1�1AMz6Dict[weakref.ref[_ConnectionFairy], _ConnectionRecord]r>c��\rSrSrSrSr\R(aSSjrSSjr	SSjr368SSjr\SSj5r
\SS	j5rSS369jrSSjrSSjrSS
jrSrg)r[i"aA connection-like adapter for a :pep:`249` DBAPI connection, which370includes additional methods specific to the :class:`.Pool` implementation.371 372:class:`.PoolProxiedConnection` is the public-facing interface for the373internal :class:`._ConnectionFairy` implementation object; users familiar374with :class:`._ConnectionFairy` can consider this object to be equivalent.375 376.. versionadded:: 2.0  :class:`.PoolProxiedConnection` provides the public-377   facing interface for the :class:`._ConnectionFairy` internal class.378 379r(c��gr@r(rgs r2r:�PoolProxiedConnection.commit3s��#r1c��gr@r(�rB�args�kwargss   r2�cursor�PoolProxiedConnection.cursor5s��Cr1c��gr@r(rgs r2r;�PoolProxiedConnection.rollback7s��Cr1c��gr@r(�rB�keys  r2�__getattr__�!PoolProxiedConnection.__getattr__9s��r1c��[5e)z_Return True if this :class:`.PoolProxiedConnection` still refers380to an active DBAPI connection.rSrgs r2r��PoolProxiedConnection.is_valid;�
��381"�#�#r1c��[5e)zNReturn True if this :class:`.PoolProxiedConnection` is detached382from its pool.rSrgs r2�is_detached�!PoolProxiedConnection.is_detachedBr�r1c��[5e)a�Separate this connection from its Pool.383 384This means that the connection will no longer be returned to the385pool when closed, and will instead be literally closed.  The386associated :class:`.ConnectionPoolEntry` is de-associated from this387DBAPI connection.388 389Note that any overall connection limiting constraints imposed by a390Pool implementation may be violated after a detach, as the detached391connection is removed from the pool's knowledge and control.392 393rSrgs r2rq�PoolProxiedConnection.detachIs
��"�#�#r1c��[5e)a�Release this connection back to the pool.394 395The :meth:`.PoolProxiedConnection.close` method shadows the396:pep:`249` ``.close()`` method, altering its behavior to instead397:term:`release` the proxied connection back to the connection pool.398 399Upon release to the pool, whether the connection stays "opened" and400pooled in the Python process, versus actually closed out and removed401from the Python process, is based on the pool implementation in use and402its configuration and current state.403 404rSrgs r2rK�PoolProxiedConnection.closeYr�r1c��U$r@r(rgs r2�	__enter__�PoolProxiedConnection.__enter__hs���r1c�$�UR5 gr@rJ)rB�exc_type�	exc_value�	tracebacks    r2�__exit__�PoolProxiedConnection.__exit__ks���405�406��r1Nr��r~rrrr\r�r�r�r\rr�)r\r)r�rr�rr�rr\r])r)r*r+r,r-r.�typingrr:r�r;r�r�r�r�rqrKr�r�r0r(r1r2r[r["s]��407��I�
���%�G�'�3�
�$��$��$��$�$� 
$��r1r[c���\rSrSr%SrSrS\S'S\S'SSjr\SS	j5r	\SS408j5r409\SSj5rSSS
jjr\
RSSj5rSSjrSSjrSrg)�_AdhocProxiedConnectionipaLprovides the :class:`.PoolProxiedConnection` interface for cases where410the DBAPI connection is not actually proxied.411 412This is used by the engine internals to pass a consistent413:class:`.PoolProxiedConnection` object to consuming dialects in response to414pool events that may not always have the :class:`._ConnectionFairy`415available.416 417�rCr��	_is_validrrCrsr�c�*�XlX lSUlgr�r�)rBrCr�s   r2r�� _AdhocProxiedConnection.__init__�s��418!1��"3����r1c�.�URR$r@�r�rrgs r2r�)_AdhocProxiedConnection.driver_connection�s���&�&�8�8�8r1c��UR$r@r(rgs r2rX�"_AdhocProxiedConnection.connection�s���$�$�$r1c��UR$)z�Implement is_valid state attribute.419 420for the adhoc proxied connection it's assumed the connection is valid421as there is no "invalidate" routine.422 423�r�rgs r2r�� _AdhocProxiedConnection.is_valid�s���~�~�r1Nc��SUlgrr�r	s   r2r��"_AdhocProxiedConnection.invalidate�s����r1c�.�URR$r@�r�rrgs r2r�#_AdhocProxiedConnection.record_info�s���&�&�2�2�2r1c�:�URR"U0UD6$r@�rCr�r}s   r2r��_AdhocProxiedConnection.cursor�s���$�$�+�+�T�<�V�<�<r1c�.�[URU5$r@�r�rCr�s  r2r��#_AdhocProxiedConnection.__getattr__�����t�,�,�c�2�2r1)r�r�rC)rCrr�rs)r\rrjr�rrr
r�)r�rr\r)r)r*r+r,r-r.r/r�r�rrXr�r�r�ro_non_memoized_propertyrr�r�r0r(r1r2r�r�ps����H�I�%�%�+�+��)��/���9��9��%��%�����?D��(��7;��	
��424425�"�"�3�#�3�=�3r1r�c���\rSrSr%SrSrS\S'S\S'S\S	'S#S426jrS\S'\S$S
j5r	\\427R"SS5S%Sj55r\
S&S'Sjj5rS(SjrS)S*SjjrS+SjrS,Sjr\S-Sj5r\S.Sj5r\S.Sj5r\428R,S/Sj5r\429R0S0Sj5rS1S2SjjrS3SjrS4SjrS+SjrS+S jrS)S5S!jjrS"r g)6r�i�a�Proxies a DBAPI connection and provides return-on-dereference430support.431 432This is an internal object used by the :class:`_pool.Pool` implementation433to provide context management to a DBAPI connection delivered by434that :class:`_pool.Pool`.   The public facing interface for this class435is described by the :class:`.PoolProxiedConnection` class.  See that436class for public API details.437 438The name "fairy" is inspired by the fact that the439:class:`._ConnectionFairy` object's lifespan is transitory, as it lasts440only for the length of a specific DBAPI connection being checked out from441the pool, and additionally that as a transparent proxy, it is mostly442invisible.443 444.. seealso::445 446    :class:`.PoolProxiedConnection`447 448    :class:`.ConnectionPoolEntry`449 450 451)rCr��_echorp�_counterrrrur"rrCrxr�c�B�XlSUlX lX0lX@lg)Nr)rpr�rCr�r�)rBr"rCr�rys     r2r��_ConnectionFairy.__init__�s!���452���
� 0��"3���453r1�Optional[_ConnectionRecord]r�c�J�URcgURR$r@r�rgs r2r�"_ConnectionFairy.driver_connection�s#���"�"�*���&�&�8�8�8r1r&zWThe _ConnectionFairy.connection attribute is deprecated; please use 'driver_connection'c��UR$r@r(rgs r2rX�_ConnectionFairy.connection�r*r1Nc��U(d3[RU5nUb[R"U5UlUR454cS5eURcS5eU=RS-
slURR(dUR(aURS:waU$SnUS:�GaZUR455RnSUR456l457UR(a�U(d�UR(a&URRSUR5 URRUR5nU(dLUR(a&URRSUR5 [ R""5eO7UR(a&URRS	UR5 URRURUR458U5 U$URR)S5 UR+5 [ R8"S5e![ R$Ga(nUR&(aHURR)S459U5 UR460R+U5 UR-X7SS9 OBURR)SURU5 UR461R+U5 UR462R/5UlO]![0aPn[2R4"5 UR463R7US
S9 ASSS5 e!,(df   e=fSnAff=fUS-nSnAOeSnAf[0aUn	[2R4"5 UR464n465U466bU467R7U	S
S9 ASSS5 e!,(df   e=fSn	A	ff=fUS:�aGMAGN�)Nz,can't 'checkout' a detached connection fairyz0can't 'checkout' an invalidated connection fairyr6rrFzPool 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)Tr2z+Reconnection attempts exhausted on checkoutzThis connection is closed)r�rBr=r7�currentr�rCr�rwr�rr�r�r�r|rUr�InvalidatePoolError�DisconnectionError�invalidate_poolrr�r�r9r�rr:r;�InvalidRequestError)r?r"�threadconnsrA�attempts�connection_is_fresh�resultr�r@�be_outerrqs           r2r��_ConnectionFairy._checkout�sv���%�.�.�t�4�E��&�&-�k�k�%�&8��#�
�$�$�0�	:�9�	:�0�
�"�"�.�	>�=�	>�.�	���!����
�
�&�&�t�~�~�
�^�^�q�
 ��L�����l�"'�":�":�"@�"@��-2�E�$�$�*�S
��>�>�.� �;�;� �K�K�-�-� @� %� 6� 6��"&���!?�!?�!�2�2�"�� &�$�{�{� $��� 1� 1�%;�$)�$:�$:�!"�468#&�"9�"9�";�;� &�������)�)�G�!�2�2��469�
�
�&�&��*�*�E�,D�,D�e����r	
�����F�G�
�����%�%�&A�B�B��u�)�)�'
��$�$��K�K�$�$�9��	��,�,�7�7��:��$�$�U��$�>��K�K�$�$�M��.�.��	��,�,�7�7��:���0�0�?�?�A��*��%���*�*�,��0�0�@�@��/3�A��"�-��-�,�����"�A�
��� �
��&�&�(��2�2�C����+�+�$�/3�,���)��)�(���
��Q��l�lsz�'D1I�O4�/BN�L+�*N�+470N�5N�471M/�&	N�/472M=�9N�N�N�
O4�O/�4!O�	O/�473O,	�(O/�/O4c�>�[RURUS9$)N)rA)r�r�rprgs r2�_checkout_existing�#_ConnectionFairy._checkout_existingns���)�)�$�*�*�D�)�A�Ar1c474�r�[URURURSURUUS9 g)N)r$rA)r6rCr�rpr�)rBr$s  r2r��_ConnectionFairy._checkinqs3����!�!��#�#��J�J���J�J�"7��	475r1c�$�UR5 gr@r�rgs r2�_close�_ConnectionFairy._close|s���
�
�r1c476���URR(a:URRURUR[	UUUS95 U(dgUR477[La�U(a9UR(a'URRSUR5 ggUR(a&URRSUR5 URRU5 gUR478[LaSUR(a&URRSUR5 URRU5 gg)Nr#z.Connection %s reset, transaction already resetz Connection %s rollback-on-returnzConnection %s commit-on-return)rw�resetrCr�r!r�r7r�r�r�r|rDr8rG)rBr"r$r%r&s     r2ro�_ConnectionFairy._resets���=�=����M�M����%�%��'�'��*?�#1�!-��
���� � �N�2�$��:�:��K�K�%�%�H��-�-����:�:��K�K�%�%�:��-�-���
�
�)�)�$�/�
�
"�
"�l�
2��z�z����!�!�4��)�)��
�M�M�#�#�D�)�
3r1c�.�URR$r@)rpr�rgs r2�_logger�_ConnectionFairy._logger�s���z�z� � � r1c��URSL$r@r(rgs r2r��_ConnectionFairy.is_valid�s���$�$�D�0�0r1c��URSL$r@)r�rgs r2r��_ConnectionFairy.is_detached�s���&�&�$�.�.r1c�L�URc0$URR$r@)r�rrgs r2r�_ConnectionFairy.info�s%���"�"�*��I��*�*�/�/�/r1c�J�URcgURR$r@r�rgs r2r�_ConnectionFairy.record_info�s#���"�"�*���*�*�6�6�6r1c���URc[R"S5 gUR(aURR	XS9 U(dSUlUR5 gg)Nz.Can't invalidate an already-closed connection.)r�r479)rCrrIr�r�r�r	s   r2r��_ConnectionFairy.invalidate�s]��� � �(��I�I�F�G���"�"��#�#�.�.��.�>��%)�D�!�
�M�M�O�
r1c�X�URceURR"U0UD6$r@r�r}s   r2r��_ConnectionFairy.cursor�s0���$�$�0�0�0��$�$�+�+�T�<�V�<�<r1c�.�[URU5$r@r�r�s  r2r��_ConnectionFairy.__getattr__�r�r1c��URb�URnSUlSUlURR	UR5 UR480R
5UlSUlURRR(a1URRRURU5 gggr@)	r�rrCrpr�r�copyrwrqrps  r2rq�_ConnectionFairy.detach�s����"�"�.��)�)�C� �C�M�#'�C� ��J�J�&�&�t�'>�'>�?��	�	���(�D�I�&*�D�#��z�z�"�"�)�)��481�482�#�#�*�*�4�+@�+@�#�F�*�/r1c�p�U=RS-slURS:XaUR5 gg)Nr6r�r�r�rgs r2rK�_ConnectionFairy.close�s*���
�
���
��=�=�A���M�M�O�r1c�n�U=RS-slURS:XaURUS9 gg)Nr6rr5r�)rB�transaction_resets  r2�_close_special�_ConnectionFairy._close_special�s0���
�
���
��=�=�A���M�M�0A�M�B�r1)r�r�r�rprCr)r"rurCrr�r�ryrxrjrj)NN)r"rur�zOptional[threading.local]rA�Optional[_ConnectionFairy]r\r�)r\r�)F)r$r'r\r]r�)483r"rur$r'r%r'r&r'r\r])r\zlog._IdentifiedLoggerTyper�rr
rrr�r�)r�r'r\r])!r)r*r+r,r-r.r/r�r�rrrkrXrlr�r�r�r�ror�r�r�rrr�rr�r�r�rqrKr�r0r(r1r2r�r��s����0�I��J�%�%������*��-�	�484 ��4�3�
�9��9�485�	�_�_�
�	)��486%���%��26�,0�	{C��{C�/�{C�*�	{C�487488�{C��{C�zB�	489��)*��)*� $�)*��	)*�490�)*�491�
)*�V�!��!��1��1��/��/�492���0��0�493�"�"�7�#�7�?D��(��7;��	
�� =�3�G�"�494C�Cr1r�)FN)rCr�r�r�r"rur7rryzOptional[log._EchoFlagType]r$r'rAr�r\r])@r-�495__future__r�collectionsr�dataclasses�enumr�	threadingr�r�rrrr	r496rrr
rrr=rVrrrr�util.typingrrr�engine.interfacesrrrrrr�sql._typingr�	dataclassr!r4r��listr7r8r9r=rardrm�497Identified�EventTargetrur�rsr�r6r>r/r[r�r�r(r1r2�<module>rs���,�"������
��������� �������!�"���3�/�+�'�'�"�'�
���d�#�)�)�$�)�X������3�4�6���,0�498�+;�(���j� � �F���/�X�/�I��I�{$�3�>�>�5�,�,�{$�|	y$�y$�x$�+�$�DZE�+�ZE�J	#(�(,�A�/�A�2�A��A�499�	A�&�A� �A�&�A�500�A�T��!��501K�-�K�\83�3�83�vIC�,�ICr1
codekingpro/portable-devtools · Team Ai