File: //usr/local/lib/python3.10/dist-packages/sqlalchemy/pool/__pycache__/events.cpython-310.pyc
o
���g]3 � @ s� d dl mZ d dlZd dlmZ d dlmZ d dlmZ d dlmZ ddlmZ dd lm Z dd
lm
Z
ddlmZ dd
lm
Z
ddlmZ ejrUddlmZ ddlmZ G dd� de
je �ZdS )� )�annotationsN)�Any)�Optional)�Type)�Union� )�ConnectionPoolEntry)�Pool)�PoolProxiedConnection)�PoolResetState� )�event)�util)�Engine)�DBAPIConnectionc @ s� e Zd ZdZdZeZe�d�e d6d
d���Z
e d7dd��Zd8dd�Zd8dd�Z
d9dd�Zd:d d!�Ze�d"ddgd#d$� �d;d'd(��Zd<d+d,�Zd<d-d.�Zd8d/d0�Zd8d1d2�Zd=d3d4�Zd5S )>�
PoolEventsa� Available events for :class:`_pool.Pool`.
The methods here define the name of an event as well
as the names of members that are passed to listener
functions.
e.g.::
from sqlalchemy import event
def my_on_checkout(dbapi_conn, connection_rec, connection_proxy):
"handle an on checkout event"
event.listen(Pool, "checkout", my_on_checkout)
In addition to accepting the :class:`_pool.Pool` class and
:class:`_pool.Pool` instances, :class:`_events.PoolEvents` also accepts
:class:`_engine.Engine` objects and the :class:`_engine.Engine` class as
targets, which will be resolved to the ``.pool`` attribute of the
given engine or the :class:`_pool.Pool` class::
engine = create_engine("postgresql+psycopg2://scott:tiger@localhost/test")
# will associate with engine.pool
event.listen(engine, "checkout", my_on_checkout)
�SomeEngineOrPoolzsqlalchemy.engine�target�-Union[Pool, Type[Pool], Engine, Type[Engine]]�
identifier�str�return�!Optional[Union[Pool, Type[Pool]]]c C sr t jstjjj}t|t�rt||�rt S t|t �sJ �|S t||�r%|j
S t|t �r,|S t|d�r7|�� d S d S )N�_no_async_engine_events)
�typing�
TYPE_CHECKINGr � preloaded�enginer �
isinstance�type�
issubclassr �pool�hasattrr )�clsr r r � r$ �A/usr/local/lib/python3.10/dist-packages/sqlalchemy/pool/events.py�_accept_with= s
zPoolEvents._accept_with� event_key�event._EventKey[Pool]�kwr �Nonec K s( |j }|�d|j� |jdi |�� d S )N�asyncior$ )�dispatch_target�
setdefault�_is_asyncio�base_listen)r# r'