�
l\�g]3 � �� � d dl mZ d dlZd dlmZ d dlmZ d dlmZ d dlmZ ddlmZ dd lm Z dd
lm
Z
ddlmZ dd
lm
Z
ddlmZ ej rddlmZ ddlmZ G d� de
j e � � ZdS )� )�annotationsN)�Any)�Optional)�Type)�Union� )�ConnectionPoolEntry)�Pool)�PoolProxiedConnection)�PoolResetState� )�event)�util)�Engine)�DBAPIConnectionc �� � e Zd ZdZdZeZ ej d� � e d)d
�� � � � Z
e d*d�� � Zd+d�Zd+d�Z
d,d�Zd-d�Z ej dddgd� � � d.d �� � Zd/d#�Zd/d$�Zd+d%�Zd+d&�Zd0d'�Zd(S )1�
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 �| � t j st j j j }t
|t � � r0t ||� � rt S t |t � � sJ �|S t
||� � r|j
S t
|t � � r|S t |d� � r|� � � d S d S )N�_no_async_engine_events)
�typing�
TYPE_CHECKINGr � preloaded�enginer �
isinstance�type�
issubclassr
�pool�hasattrr )�clsr r r s �f/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/sqlalchemy/pool/events.py�_accept_withzPoolEvents._accept_with= s� � � �#� 2��^�*�1�F��f�d�#�#�
��&�&�)�)�
���!�&�$�/�/�/�/�/��
�
���
'�
'� ��;��
���
%�
%� ��M�
�V�6�
7�
7� ��*�*�,�,�,�,�,��4� � event_key�event._EventKey[Pool]�kwr �Nonec �d � |j }|� d|j � � |j di |�� d S )N�asyncio� )�dispatch_target�
setdefault�_is_asyncio�base_listen)r&