Hacked By AnonymousFox
�
�܋f�1 � �Z � d Z ddlmZ ddlmZ G d� de� � Z G d� de� � ZdS ) a Deprecated core event interfaces.
.. deprecated:: 0.7
As of SQLAlchemy 0.7, the new event system described in
:ref:`event_toplevel` replaces the extension/proxy/listener system,
providing a consistent interface to all events without the need for
subclassing.
� )�event)�utilc �@ � e Zd ZdZed� � � Zd� Zd� Zd� Zd� Z dS )�PoolListenera� Hooks into the lifecycle of connections in a :class:`_pool.Pool`.
.. deprecated:: 0.7
:class:`.PoolListener` is deprecated and will be removed in a future
release. Please refer to :func:`.event.listen` in conjunction with
the :class:`_events.PoolEvents` listener interface.
Usage::
class MyListener(PoolListener):
def connect(self, dbapi_con, con_record):
'''perform connect operations'''
# etc.
# create a new pool with a listener
p = QueuePool(..., listeners=[MyListener()])
# add a listener after the fact
p.add_listener(MyListener())
# usage with create_engine()
e = create_engine("url://", listeners=[MyListener()])
All of the standard connection :class:`~sqlalchemy.pool.Pool` types can
accept event listeners for key connection lifecycle events:
creation, pool check-out and check-in. There are no events fired
when a connection closes.
For any given DB-API connection, there will be one ``connect``
event, `n` number of ``checkout`` events, and either `n` or `n - 1`
``checkin`` events. (If a ``Connection`` is detached from its
pool via the ``detach()`` method, it won't be checked back in.)
These are low-level events for low-level objects: raw Python
DB-API connections, without the conveniences of the SQLAlchemy
``Connection`` wrapper, ``Dialect`` services or ``ClauseElement``
execution. If you execute SQL through the connection, explicitly
closing all cursors and other resources is recommended.
Events also receive a ``_ConnectionRecord``, a long-lived internal
``Pool`` object that basically represents a "slot" in the
connection pool. ``_ConnectionRecord`` objects have one public
attribute of note: ``info``, a dictionary whose contents are
scoped to the lifetime of the DB-API connection managed by the
record. You can use this shared storage area however you like.
There is no need to subclass ``PoolListener`` to handle events.
Any class that implements one or more of these methods can be used
as a pool listener. The ``Pool`` will inspect the methods
provided by a listener object and add the listener to one or more
internal event queues based on its capabilities. In terms of
efficiency and function call overhead, you're much better off only
providing implementations for the hooks you'll be using.
c �P � g d�}t j ||�� � }|D ]Z}t t |� � }t ||d� � }|�0t j ||� � st j d|�d|�d�� � �[t
|d� � rt j |d|j � � t
|d� � rt j |d|j
� � t
|d � � rt j |d |j � � t
|d
� � rt j |d
|j � � dS dS )z^Adapt a :class:`.PoolListener` to individual
:class:`event.Dispatch` events.
)�connect�
first_connect�checkout�checkin)�methodsNz
PoolListener.z� is deprecated. The PoolListener class will be removed in a future release. Please transition to the @event interface, using @event.listens_for(Engine, '�').r r r
r )
r �as_interface�getattrr �methods_equivalent�warn_deprecated�hasattrr �listenr r r
r )�cls�self�listenerr �meth�me_meth�ls_meths �L/opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/interfaces.py�_adapt_listenerzPoolListener._adapt_listenerR sZ � � F�E�E���$�X�w�?�?�?��� � �D��l�D�1�1�G��h��d�3�3�G��"�4�+B���,� ,�"� �$�$� BF���t�t�t�M�� � �� �8�Y�'�'� <��L��y�(�*:�;�;�;��8�_�-�-� H��L����0F�G�G�G��8�Z�(�(� >��L��z�8�+<�=�=�=��8�Y�'�'� <��L��y�(�*:�;�;�;�;�;� <� <� c � � dS )a( Called once for each new DB-API connection or Pool's ``creator()``.
dbapi_con
A newly connected raw DB-API connection (not a SQLAlchemy
``Connection`` wrapper).
con_record
The ``_ConnectionRecord`` that persistently manages the connection
N� �r � dbapi_con�
con_records r r zPoolListener.connects � � � � r c � � dS )a Called exactly once for the first DB-API connection.
dbapi_con
A newly connected raw DB-API connection (not a SQLAlchemy
``Connection`` wrapper).
con_record
The ``_ConnectionRecord`` that persistently manages the connection
Nr r s r r zPoolListener.first_connect r"