L iBUdZddlmZddlmZddlZddlmZddlZddl Z ddl Z ddl m Z ddl m Z ddl m Z dd l mZdd l mZdd l mZdd l mZdd l mZddl mZddl mZddlZddlmZddlmZddlmZddlmZddlmZddlmZer*ddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddl%m&Z&ejNdGd d!Z(Gd"d#eZ)ee)ed$fZ*e+e)\Z,Z-Z.Gd%d&Z/Gd'd(e/Z0Gd)d*eZ1Gd+d,eZ2Gd-d.ejfejhZ5Gd/d0Z6Gd1d2e6Z7Gd3d4e7Z8 d> d?d5Z9iZ:d6e;d7<Gd8d9e6Z<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)frozenc8eZdZUdZdZded< ded< ded<y)PoolResetStatezdescribes 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_resetterminate_only asyncio_safeboolr"r#r$N)__name__ __module__ __qualname____doc__ __slots____annotations__Z/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sqlalchemy/pool/base.pyr r 0s4LI  r-r ceZdZdZdZdZdZy) ResetStylez1Describe options for "reset on return" behaviors.rrN)r&r'r(r)reset_rollback reset_commit reset_noner,r-r.r0r0]s;NLJr-r0)TNFcommitrollbackcHeZdZdZdZdZd dZd dZd dZd dZ d dZ d dZ y ) _ConnDialectzpartial 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$|jyN)r6selfdbapi_connections r. do_rollbackz_ConnDialect.do_rollbackys!!#r-c$|jyr:)r5r;s r. do_commitz_ConnDialect.do_commit|s!r-c$|jyr:closer;s r. do_terminatez_ConnDialect.do_terminate r-c$|jyr:rBr;s r.do_closez_ConnDialect.do_closerEr-ctd)NzJThe ping feature requires that a dialect is passed to the connection pool.NotImplementedErrorr;s r._do_ping_w_eventz_ConnDialect._do_ping_w_events! -  r-c|Sr:r,)r< connections r.get_driver_connectionz"_ConnDialect.get_driver_connectionsr-N)r=PoolProxiedConnectionreturnNone)r=rrPrQ)r=rrPr%)rMrrPr) r&r'r(r)is_async has_terminater>r@rDrGrKrNr,r-r.r8r8ls1HM$"!! r-r8ceZdZdZy)_AsyncConnDialectTN)r&r'r(rRr,r-r.rUrUsHr-rUceZdZddZy)_CreatorFnTypecyr:r,r<s r.__call__z_CreatorFnType.__call__r-NrPrr&r'r(rZr,r-r.rWrWs.r-rWceZdZddZy)_CreatorWRecFnTypecyr:r,r<recs r.rZz_CreatorWRecFnType.__call__r[r-N)rbConnectionPoolEntryrPrr]r,r-r.r_r_sHr-r_ceZdZUdZded<ded<ded<eZded <d ed <d ed <ded< d# d$dZejd%dZ e d&dZ e j d'dZ e jd(dZ d)dZdd d*dZd+dZ d, d-dZd.dZd(dZd/dZd0dZd+d Zd0d!Zd1d"Zy)2Poolz)Abstract base class for connection pools.zdispatcher[Pool]dispatchlog._EchoFlagTypeecho Optional[str]_orig_logging_namezUnion[_ConnDialect, Dialect]_dialect)Union[_CreatorFnType, _CreatorWRecFnType] _creator_argr__invoke_creatorfloat_invalidate_timeNFc |r|x|_|_nd|_tj||||_||_d|_||_tj|tjddgtjgdtjdgid|_||_| 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)noneNFr5reset_on_returnF)only_propagate) logging_namerjrinstance_logger_creator_recyclerp _pre_pingrparse_user_argument_for_enumr0r2r4r3_reset_on_returnrhrf_updaterkrlisten) r<creatorrecyclerhrvrteventsdialectpre_ping _dispatchfntargets r.__init__z Pool.__init__sX :F FD  7&*D # D40  !! $ A A ))J+=%%'<''(  !   MM ! !)E ! B #DM $ / F T62. / r-c.|jjSr:)rkrRrYs r. _is_asynciozPool._is_asyncio1s}}%%%r-c|jSr:)rmrYs r.rxz Pool._creator5s   r-c>||_|j||_yr:)rm_should_wrap_creatorrn)r<rs r.rxz Pool._creator9s!$ $88Ar-c |`|`yr:)rmrnrYs r.rxz Pool._creatorCs    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 |fdcYSwxYw) zlDetect if creator accepts a single argument, or is sent as a legacy style no-arg function. T)no_selfcSr:r,rb creator_fns r.z+Pool._should_wrap_creator..U z|r-rconnection_recordr:r1cSr:r,rs r.rz+Pool._should_wrap_creator..hrr-) rget_callable_argspecrx TypeErrorrrWdefaultslenr_)r<rargspec defaulted positionalsrs @r.rzPool._should_wrap_creatorIs ,// tLG    'G,,-II'!*o 1  AJ #)<(=w'G G*G4 4 A *G4 4ng6J+ ++ ,ng6J+ + ,s!B##CC terminatecT|jjd|rdnd| |r|jj|y|jj |y#t $rA}|jj d|rdndd|d t|tsYd}~yd}~wwxYw) Nz%s connection %rz Hard-closingClosingz Exception terminatingclosingz connection %rTexc_info) loggerdebugrkrDrG BaseExceptionerror isinstance Exception)r<rMres r._close_connectionzPool._close_connectionjs  'NY   **:6 &&z2  KK  i]YGH !   a+, sAA B'&7B""B'ct|S)z6Called by subclasses to create a new ConnectionRecord.)_ConnectionRecordrYs r._create_connectionzPool._create_connections!&&r-ct|dd}|r|j|jkrtj|_|r t|ddr|j |yyy)aMark 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_recordNis_validF)getattrrp starttimetime invalidate)r<rM exception_checkinrbs r. _invalidatezPool._invalidatesX j"6=d++cmm;$(IIKD !  J>  ! !) ,?8r-ct)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.recreates "##r-ct)zDispose 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)zReturn 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.connects ))$//r-c&|j|y)zGiven 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_connr<records r. _return_connzPool._return_conns V$r-ct)z7Implementation for :meth:`get`, supplied by subclasses.rIrYs r._do_getz Pool._do_get "##r-ct)z?Implementation for :meth:`return_conn`, supplied by subclasses.rIrs r.rzPool._do_return_connrr-ct)z6Returns a brief description of the state of this pool.rIrYs r.statusz Pool.status !##r-)NNTNNFN)rrlrintrhrgrvrirt_ResetStyleArgTyperz+Optional[List[Tuple[_ListenerFnType, str]]]rz&Optional[Union[_ConnDialect, Dialect]]rr%rzOptional[_DispatchCommon[Pool]]rPr%)rPrl)rrlrPrQrPrQ)rrlrPr_)rMrrr%rPrQ)rPrcNT)rMrOrOptional[BaseException]rr%rPrQ)rPre)rPrO)rrcrPrQ)rPstr)r&r'r(r)r+r8rkrrhybridpropertyrpropertyrxsetterdeleterrrrrrrrrrrrr,r-r.reres3 %%-9^H*;;;'' "&&*.2>B:>59H/:H/H/ H/ $ H/ , H/<H/8H/H/3H/T &&!!__B@B BB!! ,@, ,DAF)9= .'.2 -)-+- -  -, $ $0%$ $ $r-receZdZUdZdZded< ded< ejd dZejd dZ 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_connectionct)aInfo 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-ct)aPersistent 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-Nct)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` rIr<rsofts r.rzManagesConnection.invalidateBs "##r-rPrrPzOptional[_InfoType]NFrrrr%rPrQ) r&r'r(r)r*r+rro_memoized_propertyrrrr,r-r.rrs}I//(%$( $$2 $$0?D$($7;$ $r-rc.eZdZdZdZeddZddZy)rcaInterface 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,ct)z3Return True the connection is currently checked outrIrYs r.in_usezConnectionPoolEntry.in_usels "##r-ct)zAClose the DBAPI connection managed by this connection pool entry.rIrYs r.rCzConnectionPoolEntry.closerrr-Nrr)r&r'r(r)r*rrrCr,r-r.rcrcUs%(I $$ $r-rcceZdZUdZdZded<ded<ded<d ed <d$d%d Zd ed <ed&dZee jddd'dZ dZ d ed<e jd(dZe jd)dZed*dZ d$ d+dZd$d,dZed-dZed.dZd/dZ d0 d1dZd2dZd-d Zdd!d3d"Zd/d#Zy)4raMaintains 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_reffinalize_callbackfreshrr= __weakref____dict__z(Deque[Callable[[DBAPIConnection], None]]rr%r'Optional[weakref.ref[_ConnectionFairy]]rrorcd|_d|_d|_d|_||_|r|j t |_y)NFr)rrrr=_ConnectionRecord__pool_ConnectionRecord__connectrr)r<poolrs r.rz_ConnectionRecord.__init__s=  $  NN !&r-rr=cz|jy|jjj|jSr:)r=rrkrNrYs r.rz#_ConnectionRecord.driver_connections7  (;;''==%% r-2.0zXThe _ConnectionRecord.connection attribute is deprecated; please use 'driver_connection'c|jSr:r=rYs r.rMz_ConnectionRecord.connection$$$r-r_soft_invalidate_timeciSr:r,rYs r.rz_ConnectionRecord.info r-ciSr:r,rYs r.rz_ConnectionRecord.record_inforr-ctrttjnj j }jt|}tj|fdx_ }t|<rjj!d||S#t $rB}t j5j|dddd#1swYxYwd}~wwxYw)NF_fairy_was_createdc6ttd|dSdS)NFr")_finalize_fairy)refrhrrbs r.rz,_ConnectionRecord.checkout..s1#. #tS$e  r-z#Connection %r checked out from pool)rrrrget_connectionrr safe_reraise_checkin_failed_should_log_debugrweakrefr r_strong_ref_connection_recordsrr)clsrr=errfairyr rhrbs ` @@r.checkoutz_ConnectionRecord.checkouts ($,,.9C,,.C "113 %%' '7dC%kk     /2&s+  KK  57G  3 ""$ C##CE#B C   C   s/B33 C><C9C-$ C9-C6 2C99C>cL|j||j|y)Nrr)rcheckin)r<rr s r.rz!_ConnectionRecord._checkin_faileds& # 1  r-c|j|rtjd|zyd|_|j}|j}|j r1|j j }||||j r1|jjr|jj|||j|y)NzDouble checkin attempted on %s) rrwarnr=rrpoprfrr)r<r rMr finalizers r.rz_ConnectionRecord.checkins >> !&8 II6= > ** {{$$..224I%*%$$ == MM ! !*d 3 $r-c|jduSr:)rrYs r.rz_ConnectionRecord.in_uses~~T))r-c|jSr:)rrYs r.last_connect_timez#_ConnectionRecord.last_connect_time s ~~r-c>|j|jyyr:)r=_ConnectionRecord__closerYs r.rCz_ConnectionRecord.close s  , LLN -r-NFcX|jy|r2|jjj|j||n1|jjj |j|||L|jj j d|rdnd|j|jj|n5|jj j d|rdnd|j|rtj|_ y|jdd|_y)Nz*%sInvalidate connection %r (reason: %s:%s)zSoft z%sInvalidate connection %rTr) r=rrfsoft_invalidaterrr __class__r&rrr#rs r.rz_ConnectionRecord.invalidates  (   KK 0 0%%tQ  KK + +D,A,A4 K = KK   # #<R%% $$   KK   # #,R%%  )-D & LL4L ($(D !r-cpd}|j,|jj|jn%|jj dkDrkt j |jz |jj kDr3|jjjd|jd}n|jj|jkDr3|jjjd|jd}nK|j|jkDr2|jjjd|jd}|r<|jd|jj|j|jJ|jS)NFrz)Connection %r exceeded timeout; recyclingTz=Connection %r invalidated due to pool invalidation; recyclingzCConnection %r invalidated due to local soft invalidation; recyclingr) r=rclearrrryrrrrprr#)r<rs r.rz _ConnectionRecord.get_connection2sT  ( IIOO  NN  KK 2 % dnn,t{{/C/CC KK   # #;%% G [[ ) )DNN : KK   # #%%  G  ' '$.. 8 KK   # #%%  G  LL4L ( IIOO  NN $$000$$$r-c|jduxs>|jj|jkDxs|j|jkDSr:)r=rrprrrYs r._is_hard_or_soft_invalidatedz._ConnectionRecord._is_hard_or_soft_invalidatedfsG  ! !T ) ={{++dnn< =**T^^; r-rcP|jj|jjjr0|jjj |j ||j J|jj |j |d|_y)Nr)rr)rrfrCr=r)r<rs r.__closez_ConnectionRecord.__closems $$& ;;   % % KK & &t'<' ? ? ? ? ? ?s0AD E0E+/E E+E E++E0)T)rrerr%rPr)rPrrr)rrerPr)rrr r%rPrQ)r r%rPrQr)rProrrrr\)rr%rPrQ)r&r'r(r)r*r+rrrr deprecatedrMrrrr classmethodrrrrr!rCrrr+r#rr,r-r.rrws^" I@? K66 )0/ T__  ) %  %$%5$  !!H>B   6:   .** ?D)()7;) )B2%h ,1%Er-rc|du}|r>|Jtj|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|Jt||||}|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,sYd} ~ 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!rz!Exception during reset or similarrrzFThe 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.)rrrr=rr rkrRrSrrr_reset_pooldetachrfclose_detachedrrrrrrrrrr)r=rrr rhr"r is_gc_cleanupdont_restore_gcedr;can_manipulate_connection!can_close_or_terminate_connectionrequires_terminate_for_closermessages r.r r s;(tOM&**35 ,,,  & &c 1 ''',== &**7;;u+=tD .."d*;m(5$5! && & E$--*E*E * MM " " Bt}}'B'B % #d*HLL!$E',$#  KK  68H 9 #(444($%  ))-== == LL&;%6  $"&EKLLN4}}33 445EF**(">+-,=11A0DE' AE)'' ' !!'* '".88D!!#  !%#'  O  KK  3d  !!,,q,1a+,  -,=11A0DE' AE)'' ' !!'* '"!->-vs-BH.. J7AI>9J>JJAKz6Dict[weakref.ref[_ConnectionFairy], _ConnectionRecord]rceZdZdZdZej rd dZd dZd dZ ddZ e ddZ e ddZ d d Zd d 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,cyr:r,rYs r.r5zPoolProxiedConnection.commit2r[r-cyr:r,r<argskwargss r.cursorzPoolProxiedConnection.cursor4r[r-cyr:r,rYs r.r6zPoolProxiedConnection.rollback6r[r-cyr:r,r<keys r. __getattr__z!PoolProxiedConnection.__getattr__8r[r-ct)zgReturn True if this :class:`.PoolProxiedConnection` still refers to an active DBAPI connection.rIrYs r.rzPoolProxiedConnection.is_valid: "##r-ct)zVReturn True if this :class:`.PoolProxiedConnection` is detached from its pool.rIrYs r. is_detachedz!PoolProxiedConnection.is_detachedArPr-ct)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-ct)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.closeXrr-NrrGrrHrrPrrMrrPrr)r&r'r(r)r*typingrr5rIr6rNrrrRr;rCr,r-r.rOrO!sS I %G'3 $$ $$ $ $r-rOceZdZUdZdZded<ded< ddZeddZedd Z edd Z d dd Z e jdd ZddZddZy )_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=rcrc.||_||_d|_yrrZ)r<r=rs r.rz _AdhocProxiedConnection.__init__xs !1"3r-c.|jjSr:rrrYs r.rz)_AdhocProxiedConnection.driver_connections&&888r-c|jSr:rrYs r.rMz"_AdhocProxiedConnection.connections$$$r-c|jS)zImplement is_valid state attribute. for the adhoc proxied connection it's assumed the connection is valid as there is no "invalidate" routine. r[rYs r.rz _AdhocProxiedConnection.is_valids~~r-Ncd|_yrrars r.rz"_AdhocProxiedConnection.invalidates r-c.|jjSr:rrrYs r.rz#_AdhocProxiedConnection.record_infos&&222r-c:|jj|i|Sr:r=rIrFs r.rIz_AdhocProxiedConnection.cursors +t$$++T = > . ! &&t~~ ^^q Ll"'":":"@"@ -2E $ $ *S >>. ;; KK-- @ % 6 6"&!?!?!22" &${{ $ 1 1%;$)$:$:!" #&"9"9";; ))G!22  &&**E,D,De r FG %%&ABBu))' $$KK$$9  ,,77:$$UA$>KK$$M..  ,,77:00??A*%**, "00@@/3A" " ""A   &&( 22C++$/3,   QlszDH$$N38BMK32M3 M <ML8/ M8M =MM  M N3"N.6#N" N."N+ 'N..N3cDtj|j|S)N)r)rrr:rYs r._checkout_existingz#_ConnectionFairy._checkout_existingfs))$**D)AAr-c xt|j|j|jd|j||y)N)r"r)r r=rr:rl)r<r"s r.rz_ConnectionFairy._checkinis3  ! !  # # JJ  JJ"7 r-c$|jyr:rsrYs r._closez_ConnectionFairy._closets  r-c |jjr=|jj|j|jt ||||sy|j t ur|r3|jru|jjd|jy|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)rfresetr=rr r|r2rlrrrkr>r3r@)r<rr"r#r$s r.r9z_ConnectionFairy._resetws ==   MM  %%''*?#1!-    N 2$::KK%%H-- ::KK%%:-- ))$/ " "l 2zz !!4)) MM # #D ) 3r-c.|jjSr:)r:rrYs r._loggerz_ConnectionFairy._loggerszz   r-c|jduSr:rrYs r.rz_ConnectionFairy.is_valids$$D00r-c|jduSr:)rrYs r.rRz_ConnectionFairy.is_detacheds&&$..r-cJ|jiS|jjSr:)rrrYs r.rz_ConnectionFairy.infos%  " " *I**// /r-cH|jy|jjSr:rdrYs r.rz_ConnectionFairy.record_infos#  " " ***66 6r-c|jtjdy|jr|jj |||sd|_|j yy)Nz.Can't invalidate an already-closed connection.)rr)r=rrrrrrs r.rz_ConnectionFairy.invalidates_  ( IIF G   " "  # # . . . >%)D ! MMO r-cV|jJ|jj|i|Sr:rfrFs r.rIz_ConnectionFairy.cursors2$$000+t$$++T'> ? (DI&*D #zz"")) ##**4+@+@#F* /r-cn|xjdzc_|jdk(r|jyy)Nr1rrmrrYs r.rCz_ConnectionFairy.closes*  ==A  MMO r-cr|xjdzc_|jdk(r|j|yy)Nr1rr r)r<transaction_resets r._close_specialz_ConnectionFairy._close_specials0  ==A  MM0AM B r-)rrer=rrrrhrgr4r\)NN)rreryzOptional[threading.local]rOptional[_ConnectionFairy]rPr)rPr)F)r"r%rPrQr) rrer"r%r#r%r$r%rPrQ)rPzlog._IdentifiedLoggerTyperrrrrrUrV)rr%rPrQ)r&r'r(r)r*r+rrrrr5rMr6rrrrr9rrrRrrrjrrrIrNr;rCrr,r-r.rrs0I J%%   * -   43 99 T__  ) %  %26,0 {C{C/{C* {C  {C{CzB  )*)* $)* )*  )*  )*V!!11// 00  ""7#7?D(7;  =3G" Cr-r)FN)r=rrrorrer rrhzOptional[log._EchoFlagType]r"r%rrrPrQ)?r) __future__r collectionsr dataclassesenumr threadingrrWrrrr r r r r rrrr%rrrr util.typingrrengine.interfacesrrrrrr sql._typingr dataclassr r0rlistr2r3r4r8rUrWr_ Identified EventTargetrerrcrr rr+rOrYrr,r-r.rs,"  !"3/+''"'d#))$)X 346,0 +;( j  F /X/II{$3>>5,,{$| y$y$x$+$DZE+ZEJ #((,A/A2A A  A &A A &A AT! D$-D$N83383vIC,ICr-