Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
events.cpython-313.pyc269 linesDownload Raw Back to __pycache__
1�

2��j6����SSKJr SSKrSSKJr SSKJr SSKJr SSKJr SSKJr SS	KJ	r	 SS3KJ4r5 SSKJr SS
KJ
r
 SSKJr \R(aSSKJr SSKJr "SS\
R(\	5rg)�)�annotationsN)�Any)�Optional)�Type)�Union�)�ConnectionPoolEntry)�Pool)�PoolProxiedConnection)�PoolResetState�)�event)�util)�Engine)�DBAPIConnectionc��\rSrSrSrSr\r\R"S5\6SSj55r\7SSj5rSS	jr
SS8jrSSjrSSjr\R$"S
SS/S5SSj5rSSjrSSjrSSjrSSjrSSjrSrg)�9PoolEvents�azAvailable events for :class:`_pool.Pool`.10 11The methods here define the name of an event as well12as the names of members that are passed to listener13functions.14 15When using an :class:`.Engine` object created via :func:`_sa.create_engine`16(or indirectly via :func:`.create_async_engine`), :class:`.PoolEvents`17listeners are expected to be registered in terms of the :class:`.Engine`,18which will direct the listeners to the :class:`.Pool` contained within::19 20    from sqlalchemy import create_engine21    from sqlalchemy import event22 23    engine = create_engine("postgresql+psycopg2://scott:tiger@localhost/test")24 25 26    @event.listens_for(engine, "checkout")27    def my_on_checkout(dbapi_conn, connection_rec, connection_proxy):28        "handle an on checkout event"29 30:class:`.PoolEvents` may also be registered with the :class:`_pool.Pool`31class, with the :class:`.Engine` class, as well as with instances of32:class:`_pool.Pool`.33 34.. tip::35 36    Registering :class:`.PoolEvents` with the :class:`.Engine`, if present,37    is recommended since the :meth:`.Engine.dispose` method will carry38    along event listeners from the old pool to the new pool.39 40�SomeEngineOrPoolzsqlalchemy.enginec��[R(d$[RRR41n[
U[5(a0[UW5(a[$[U[5(deU$[
UW5(aUR$[
U[5(aU$[US5(aUR5 gg)N�_no_async_engine_events)
�typing�
TYPE_CHECKINGr�	preloaded�enginer�42isinstance�type�43issubclassr44�pool�hasattrr)�cls�target�45identifierrs    �\D:\code\apps\devtools\python\user_packages\Python313\site-packages\sqlalchemy/pool/events.py�_accept_with�PoolEvents._accept_with@s����#�#��^�^�*�*�1�1�F��f�d�#�#��&�&�)�)���!�&�$�/�/�/�/��
�
���
'�
'��;�;��
���
%�
%��M�
�V�6�
7�
7��*�*�,��c�x�URnURSUR5 UR"S0UD6 g)N�asyncio�)�dispatch_target�46setdefault�_is_asyncio�base_listen)r!�	event_key�kwr"s    r$�_listen�PoolEvents._listenYs4���*�*��47�
�
�i��!3�!3�4����#��#r'�dbapi_connection�connection_recordc��g)a�Called at the moment a particular DBAPI connection is first48created for a given :class:`_pool.Pool`.49 50This event allows one to capture the point directly after which51the DBAPI module-level ``.connect()`` method has been used in order52to produce a new DBAPI connection.53 54:param dbapi_connection: a DBAPI connection.55 The :attr:`.ConnectionPoolEntry.dbapi_connection` attribute.56 57:param connection_record: the :class:`.ConnectionPoolEntry` managing58 the DBAPI connection.59 60Nr*��selfr3r4s   r$�connect�PoolEvents.connecte��r'c��g)a�Called exactly once for the first time a DBAPI connection is61checked out from a particular :class:`_pool.Pool`.62 63The rationale for :meth:`_events.PoolEvents.first_connect`64is to determine65information about a particular series of database connections based66on the settings used for all connections.  Since a particular67:class:`_pool.Pool`68refers to a single "creator" function (which in terms69of a :class:`_engine.Engine`70refers to the URL and connection options used),71it is typically valid to make observations about a single connection72that can be safely assumed to be valid about all subsequent73connections, such as the database version, the server and client74encoding settings, collation settings, and many others.75 76:param dbapi_connection: a DBAPI connection.77 The :attr:`.ConnectionPoolEntry.dbapi_connection` attribute.78 79:param connection_record: the :class:`.ConnectionPoolEntry` managing80 the DBAPI connection.81 82Nr*r6s   r$�
first_connect�PoolEvents.first_connectyr:r'c��g)aCalled when a connection is retrieved from the Pool.83 84:param dbapi_connection: a DBAPI connection.85 The :attr:`.ConnectionPoolEntry.dbapi_connection` attribute.86 87:param connection_record: the :class:`.ConnectionPoolEntry` managing88 the DBAPI connection.89 90:param connection_proxy: the :class:`.PoolProxiedConnection` object91  which will proxy the public interface of the DBAPI connection for the92  lifespan of the checkout.93 94If you raise a :class:`~sqlalchemy.exc.DisconnectionError`, the current95connection will be disposed and a fresh connection retrieved.96Processing of all checkout listeners will abort and restart97using the new connection.98 99.. seealso:: :meth:`_events.ConnectionEvents.engine_connect`100   - a similar event101   which occurs upon creation of a new :class:`_engine.Connection`.102 103Nr*)r7r3r4�connection_proxys    r$�checkout�PoolEvents.checkout�r:r'c��g)a�Called when a connection returns to the pool.104 105Note that the connection may be closed, and may be None if the106connection has been invalidated.  ``checkin`` will not be called107for detached connections.  (They do not return to the pool.)108 109:param dbapi_connection: a DBAPI connection.110 The :attr:`.ConnectionPoolEntry.dbapi_connection` attribute.111 112:param connection_record: the :class:`.ConnectionPoolEntry` managing113 the DBAPI connection.114 115Nr*r6s   r$�checkin�PoolEvents.checkin�r:r'z2.0c�116�UU4$)Nr*)r3r4�reset_states   r$�<lambda>�PoolEvents.<lambda>�s����B117r'c��g)a�Called before the "reset" action occurs for a pooled connection.118 119This event represents120when the ``rollback()`` method is called on the DBAPI connection121before it is returned to the pool or discarded.122A custom "reset" strategy may be implemented using this event hook,123which may also be combined with disabling the default "reset"124behavior using the :paramref:`_pool.Pool.reset_on_return` parameter.125 126The primary difference between the :meth:`_events.PoolEvents.reset` and127:meth:`_events.PoolEvents.checkin` events are that128:meth:`_events.PoolEvents.reset` is called not just for pooled129connections that are being returned to the pool, but also for130connections that were detached using the131:meth:`_engine.Connection.detach` method as well as asyncio connections132that are being discarded due to garbage collection taking place on133connections before the connection was checked in.134 135Note that the event **is not** invoked for connections that were136invalidated using :meth:`_engine.Connection.invalidate`.    These137events may be intercepted using the :meth:`.PoolEvents.soft_invalidate`138and :meth:`.PoolEvents.invalidate` event hooks, and all "connection139close" events may be intercepted using :meth:`.PoolEvents.close`.140 141The :meth:`_events.PoolEvents.reset` event is usually followed by the142:meth:`_events.PoolEvents.checkin` event, except in those143cases where the connection is discarded immediately after reset.144 145:param dbapi_connection: a DBAPI connection.146 The :attr:`.ConnectionPoolEntry.dbapi_connection` attribute.147 148:param connection_record: the :class:`.ConnectionPoolEntry` managing149 the DBAPI connection.150 151:param reset_state: :class:`.PoolResetState` instance which provides152 information about the circumstances under which the connection153 is being reset.154 155 .. versionadded:: 2.0156 157.. seealso::158 159    :ref:`pool_reset_on_return`160 161    :meth:`_events.ConnectionEvents.rollback`162 163    :meth:`_events.ConnectionEvents.commit`164 165Nr*)r7r3r4rFs    r$�reset�PoolEvents.reset�r:r'c��g)a�Called when a DBAPI connection is to be "invalidated".166 167This event is called any time the168:meth:`.ConnectionPoolEntry.invalidate` method is invoked, either from169API usage or via "auto-invalidation", without the ``soft`` flag.170 171The event occurs before a final attempt to call ``.close()`` on the172connection occurs.173 174:param dbapi_connection: a DBAPI connection.175 The :attr:`.ConnectionPoolEntry.dbapi_connection` attribute.176 177:param connection_record: the :class:`.ConnectionPoolEntry` managing178 the DBAPI connection.179 180:param exception: the exception object corresponding to the reason181 for this invalidation, if any.  May be ``None``.182 183.. seealso::184 185    :ref:`pool_connection_invalidation`186 187Nr*�r7r3r4�	exceptions    r$�188invalidate�PoolEvents.invalidater:r'c��g)a�Called when a DBAPI connection is to be "soft invalidated".189 190This event is called any time the191:meth:`.ConnectionPoolEntry.invalidate`192method is invoked with the ``soft`` flag.193 194Soft invalidation refers to when the connection record that tracks195this connection will force a reconnect after the current connection196is checked in.   It does not actively close the dbapi_connection197at the point at which it is called.198 199:param dbapi_connection: a DBAPI connection.200 The :attr:`.ConnectionPoolEntry.dbapi_connection` attribute.201 202:param connection_record: the :class:`.ConnectionPoolEntry` managing203 the DBAPI connection.204 205:param exception: the exception object corresponding to the reason206 for this invalidation, if any.  May be ``None``.207 208Nr*rMs    r$�soft_invalidate�PoolEvents.soft_invalidate$r:r'c��g)amCalled when a DBAPI connection is closed.209 210The event is emitted before the close occurs.211 212The close of a connection can fail; typically this is because213the connection is already closed.  If the close operation fails,214the connection is discarded.215 216The :meth:`.close` event corresponds to a connection that's still217associated with the pool. To intercept close events for detached218connections use :meth:`.close_detached`.219 220:param dbapi_connection: a DBAPI connection.221 The :attr:`.ConnectionPoolEntry.dbapi_connection` attribute.222 223:param connection_record: the :class:`.ConnectionPoolEntry` managing224 the DBAPI connection.225 226Nr*r6s   r$�close�PoolEvents.close@r:r'c��g)a~Called when a DBAPI connection is "detached" from a pool.227 228This event is emitted after the detach occurs.  The connection229is no longer associated with the given connection record.230 231:param dbapi_connection: a DBAPI connection.232 The :attr:`.ConnectionPoolEntry.dbapi_connection` attribute.233 234:param connection_record: the :class:`.ConnectionPoolEntry` managing235 the DBAPI connection.236 237Nr*r6s   r$�detach�PoolEvents.detachYr:r'c��g)alCalled when a detached DBAPI connection is closed.238 239The event is emitted before the close occurs.240 241The close of a connection can fail; typically this is because242the connection is already closed.  If the close operation fails,243the connection is discarded.244 245:param dbapi_connection: a DBAPI connection.246 The :attr:`.ConnectionPoolEntry.dbapi_connection` attribute.247 248Nr*)r7r3s  r$�close_detached�PoolEvents.close_detachedkr:r'r*N)r"z-Union[Pool, Type[Pool], Engine, Type[Engine]]r#�str�returnz!Optional[Union[Pool, Type[Pool]]])r/zevent._EventKey[Pool]r0rr^�None)r3rr4r	r^r_)r3rr4r	r?rr^r_)r3zOptional[DBAPIConnection]r4r	r^r_)r3rr4r	rFrr^r_)r3rr4r	rNzOptional[BaseException]r^r_)r3rr^r_)�__name__�249__module__�__qualname__�__firstlineno__�__doc__�_target_class_docr250�_dispatch_targetr�preload_module�classmethodr%r1r8r<r@rCr�_legacy_signaturerJrOrRrUrXr[�__static_attributes__r*r'r$rrs251���B+����	���,�-���=����252+�	��.��.�	$�(�	$��	$�253�		$��	$��)��/��254�	�(�)��/��255�	�:�)��/��0�	�256257��:�3��/��258�	�&���
�	�0�1�	259��6�)�6�/�6�$�	6�260261�6��6�p�)��/��+�	�262263��<�)��/��+�	�264265��8�)��/��266�	�2�)��/��267�	�$r'r)�268__future__rrrrrr�baser	r269rr�rrrrr�engine.interfacesr�Eventsrr*r'r$�<module>rpsQ��#�
�����%��'� ���	����3�\����d�#�\r'
codekingpro/portable-devtools · Team Ai