
    -h-                     R    S SK Jr  SSKJr  SSKJr   " S S\R                  5      rg)   )Pool   )event)Enginec                   |    \ rS rSrSrSr\r\S 5       r	\S 5       r
S rS rS rS	 rS
 rS rS rS rS rS rSrg)
PoolEvents   aM  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://scott:tiger@localhost/test")

    # will associate with engine.pool
    event.listen(engine, 'checkout', my_on_checkout)

SomeEngineOrPoolc                    [        U[        5      (       a3  [        U[        5      (       a  [        $ [        U[        5      (       a  U$ g [        U[        5      (       a  UR
                  $ [        U[        5      (       a  U$ [        US5      (       aJ  [        UR                  R                  S5      (       a%  UR                  R                  R                  5         g g )Ndispatch_no_async_engine_events)

isinstancetype
issubclassr   r   poolhasattrr   _eventsr   )clstargets     kC:\Users\ROHAN GUPTA\OneDrive\Desktop\mathbuddy-assessment\venv\Lib\site-packages\sqlalchemy/pool/events.py_accept_withPoolEvents._accept_with-   s    fd##&&))FD)) *'';;%%MVZ((WOO##%>.
 .
 OO##;;=    c                 x    UR                   nUR                  SUR                  5        UR                  " S0 UD6  g )Nasyncio )dispatch_target
setdefault_is_asynciobase_listen)r   	event_keykwr   s       r   _listenPoolEvents._listen?   s2    **
i!3!34##r   c                     g)a  Called at the moment a particular DBAPI connection is first
created for a given :class:`_pool.Pool`.

This event allows one to capture the point directly after which
the DBAPI module-level ``.connect()`` method has been used in order
to produce a new DBAPI connection.

:param dbapi_connection: a DBAPI connection.
 The :attr:`._ConnectionRecord.dbapi_connection` attribute.

:param connection_record: the :class:`._ConnectionRecord` managing the
 DBAPI connection.

Nr   selfdbapi_connectionconnection_records      r   connectPoolEvents.connectG       r   c                     g)a  Called exactly once for the first time a DBAPI connection is
checked out from a particular :class:`_pool.Pool`.

The rationale for :meth:`_events.PoolEvents.first_connect`
is to determine
information about a particular series of database connections based
on the settings used for all connections.  Since a particular
:class:`_pool.Pool`
refers to a single "creator" function (which in terms
of a :class:`_engine.Engine`
refers to the URL and connection options used),
it is typically valid to make observations about a single connection
that can be safely assumed to be valid about all subsequent
connections, such as the database version, the server and client
encoding settings, collation settings, and many others.

:param dbapi_connection: a DBAPI connection.
 The :attr:`._ConnectionRecord.dbapi_connection` attribute.

:param connection_record: the :class:`._ConnectionRecord` managing the
 DBAPI connection.

Nr   r&   s      r   first_connectPoolEvents.first_connectW   r,   r   c                     g)a  Called when a connection is retrieved from the Pool.

:param dbapi_connection: a DBAPI connection.
 The :attr:`._ConnectionRecord.dbapi_connection` attribute.

:param connection_record: the :class:`._ConnectionRecord` managing the
 DBAPI connection.

:param connection_proxy: the :class:`._ConnectionFairy` object which
  will proxy the public interface of the DBAPI connection for the
  lifespan of the checkout.

If you raise a :class:`~sqlalchemy.exc.DisconnectionError`, the current
connection will be disposed and a fresh connection retrieved.
Processing of all checkout listeners will abort and restart
using the new connection.

.. seealso:: :meth:`_events.ConnectionEvents.engine_connect`
   - a similar event
   which occurs upon creation of a new :class:`_engine.Connection`.

Nr   )r'   r(   r)   connection_proxys       r   checkoutPoolEvents.checkoutp   r,   r   c                     g)a  Called when a connection returns to the pool.

Note that the connection may be closed, and may be None if the
connection has been invalidated.  ``checkin`` will not be called
for detached connections.  (They do not return to the pool.)

:param dbapi_connection: a DBAPI connection.
 The :attr:`._ConnectionRecord.dbapi_connection` attribute.

:param connection_record: the :class:`._ConnectionRecord` managing the
 DBAPI connection.

Nr   r&   s      r   checkinPoolEvents.checkin   r,   r   c                     g)a  Called before the "reset" action occurs for a pooled connection.

This event represents when the ``rollback()`` method is called on the
DBAPI connection before it is returned to the pool or discarded. A
custom "reset" strategy may be implemented using this event hook, which
may also be combined with disabling the default "reset" behavior using
the :paramref:`_pool.Pool.reset_on_return` parameter.

The primary difference between the :meth:`_events.PoolEvents.reset` and
:meth:`_events.PoolEvents.checkin` events are that
:meth:`_events.PoolEvents.reset` is called not just for pooled
connections that are being returned to the pool, but also for
connections that were detached using the
:meth:`_engine.Connection.detach` method.

Note that the event **is not** invoked for connections that were
invalidated using :meth:`_engine.Connection.invalidate`.    These
events may be intercepted using the :meth:`.PoolEvents.soft_invalidate`
and :meth:`.PoolEvents.invalidate` event hooks, and all "connection
close" events may be intercepted using :meth:`.PoolEvents.close`.
The :meth:`_events.PoolEvents.reset` event is usually followed by the
:meth:`_events.PoolEvents.checkin` event, except in those
cases where the connection is discarded immediately after reset.

In the 1.4 series, the event is also not invoked for asyncio
connections that are being garbage collected without their being
explicitly returned to the pool. This is due to the lack of an event
loop which prevents "reset" operations from taking place. Version 2.0
will feature an enhanced version of :meth:`.PoolEvents.reset` which is
invoked in this scenario while passing additional contextual
information indicating that an event loop is not guaranteed
to be present.

:param dbapi_connection: a DBAPI connection.
 The :attr:`._ConnectionRecord.dbapi_connection` attribute.

:param connection_record: the :class:`._ConnectionRecord` managing the
 DBAPI connection.

.. seealso::

    :meth:`_events.ConnectionEvents.rollback`

    :meth:`_events.ConnectionEvents.commit`

Nr   r&   s      r   resetPoolEvents.reset   r,   r   c                     g)a  Called when a DBAPI connection is to be "invalidated".

This event is called any time the :meth:`._ConnectionRecord.invalidate`
method is invoked, either from API usage or via "auto-invalidation",
without the ``soft`` flag.

The event occurs before a final attempt to call ``.close()`` on the
connection occurs.

:param dbapi_connection: a DBAPI connection.
 The :attr:`._ConnectionRecord.dbapi_connection` attribute.

:param connection_record: the :class:`._ConnectionRecord` managing the
 DBAPI connection.

:param exception: the exception object corresponding to the reason
 for this invalidation, if any.  May be ``None``.

.. versionadded:: 0.9.2 Added support for connection invalidation
   listening.

.. seealso::

    :ref:`pool_connection_invalidation`

Nr   r'   r(   r)   	exceptions       r   
invalidatePoolEvents.invalidate   r,   r   c                     g)a  Called when a DBAPI connection is to be "soft invalidated".

This event is called any time the :meth:`._ConnectionRecord.invalidate`
method is invoked with the ``soft`` flag.

Soft invalidation refers to when the connection record that tracks
this connection will force a reconnect after the current connection
is checked in.   It does not actively close the dbapi_connection
at the point at which it is called.

.. versionadded:: 1.0.3

:param dbapi_connection: a DBAPI connection.
 The :attr:`._ConnectionRecord.dbapi_connection` attribute.

:param connection_record: the :class:`._ConnectionRecord` managing the
 DBAPI connection.

:param exception: the exception object corresponding to the reason
 for this invalidation, if any.  May be ``None``.

Nr   r;   s       r   soft_invalidatePoolEvents.soft_invalidate   r,   r   c                     g)a  Called when a DBAPI connection is closed.

The event is emitted before the close occurs.

The close of a connection can fail; typically this is because
the connection is already closed.  If the close operation fails,
the connection is discarded.

The :meth:`.close` event corresponds to a connection that's still
associated with the pool. To intercept close events for detached
connections use :meth:`.close_detached`.

.. versionadded:: 1.1

:param dbapi_connection: a DBAPI connection.
 The :attr:`._ConnectionRecord.dbapi_connection` attribute.

:param connection_record: the :class:`._ConnectionRecord` managing the
 DBAPI connection.

Nr   r&   s      r   closePoolEvents.close   r,   r   c                     g)a  Called when a DBAPI connection is "detached" from a pool.

This event is emitted after the detach occurs.  The connection
is no longer associated with the given connection record.

.. versionadded:: 1.1

:param dbapi_connection: a DBAPI connection.
 The :attr:`._ConnectionRecord.dbapi_connection` attribute.

:param connection_record: the :class:`._ConnectionRecord` managing the
 DBAPI connection.

Nr   r&   s      r   detachPoolEvents.detach  r,   r   c                     g)a  Called when a detached DBAPI connection is closed.

The event is emitted before the close occurs.

The close of a connection can fail; typically this is because
the connection is already closed.  If the close operation fails,
the connection is discarded.

.. versionadded:: 1.1

:param dbapi_connection: a DBAPI connection.
 The :attr:`._ConnectionRecord.dbapi_connection` attribute.

Nr   )r'   r(   s     r   close_detachedPoolEvents.close_detached"  r,   r   r   N)__name__
__module____qualname____firstlineno____doc___target_class_docr   _dispatch_targetclassmethodr   r#   r*   r.   r2   r5   r8   r=   r@   rC   rF   rI   __static_attributes__r   r   r   r   r      sn    8 + " $ $ 20.`80. r   r   N)baser    r   engine.baser   Eventsr   r   r   r   <module>rX      s"       c cr   