gq f d Z ddlmZ ddlZddlZddlmZ ddlmZ ddlmZ ddlm Z dd lm Z dd l mZ e j d Z e j d Z e j d Z G d de Z G d de j Z G d de Z ddZ e Z G d de ZdS )z'Base constructs for connection pools. )dequeN )event)exc) interfaces)log)util) threadingreset_rollbackreset_commit reset_nonec * e Zd ZdZd Zd Zd Zd ZdS )_ConnDialectzpartial implementation of :class:`.Dialect` which provides DBAPI connection methods. When a :class:`_pool.Pool` is combined with an :class:`_engine.Engine`, the :class:`_engine.Engine` replaces this with its own :class:`.Dialect`. c . | d S N)rollbackselfdbapi_connections h/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib64/python3.11/site-packages/sqlalchemy/pool/base.pydo_rollbackz_ConnDialect.do_rollback) s !!##### c . | d S r )commitr s r do_commitz_ConnDialect.do_commit, s !!!!!r c . | d S r )closer s r do_closez_ConnDialect.do_close/ s r c t d )NzJThe ping feature requires that a dialect is passed to the connection pool.NotImplementedErrorr s r do_pingz_ConnDialect.do_ping2 s ! - r N)__name__ __module____qualname____doc__r r r r" r r r r sZ $ $ $" " "! ! ! r r c & e Zd ZdZ e Z ej dd dd Ze d Z e j d Z d Zd Z ej dd d Zd Zd ZddZd Zd Zd Zd Zd Zd Zd ZdS )Poolz)Abstract base class for connection pools.)z1.3zkThe :paramref:`_pool.Pool.use_threadlocal` parameter is deprecated and will be removed in a future release.)0.7z:class:`.PoolListener` is deprecated in favor of the :class:`_events.PoolEvents` listener interface. The :paramref:`_pool.Pool.listeners` parameter will be removed in a future release.)use_threadlocal listenersNFTc 4 |r|x| _ | _ nd| _ t j | | t j | _ || _ || _ d| _ || _ | | _ t j |t ddgt g dt" dgidd | _ || _ |r| j |d | r| | _ |r|D ]\ }} t/ j | | | |r|D ]}| | dS dS )a- Construct a Pool. :param creator: a callable function that returns a DB-API connection object. The function will be called with parameters. :param recycle: If set to a value other than -1, number of seconds between connection recycling, which means upon checkout, if this timeout is surpassed the connection will be closed and replaced with a newly opened connection. Defaults to -1. :param logging_name: String identifier which will be used within the "name" field of logging records generated within the "sqlalchemy.pool" logger. Defaults to a hexstring of the object's id. :param echo: if True, the connection pool will log informational output such as when connections are invalidated as well as when connections are recycled to the default log handler, which defaults to ``sys.stdout`` for output.. If set to the string ``"debug"``, the logging will include pool checkouts and checkins. The :paramref:`_pool.Pool.echo` parameter can also be set from the :func:`_sa.create_engine` call by using the :paramref:`_sa.create_engine.echo_pool` parameter. .. seealso:: :ref:`dbengine_logging` - further detail on how to configure logging. :param use_threadlocal: If set to True, repeated calls to :meth:`connect` within the same application thread will be guaranteed to return the same connection object that is already checked out. This is a legacy use case and the flag has no effect when using the pool with a :class:`_engine.Engine` object. :param reset_on_return: Determine steps to take on connections as they are returned to the pool. reset_on_return can have any of these values: * ``"rollback"`` - call rollback() on the connection, to release locks and transaction resources. This is the default value. The vast majority of use cases should leave this value set. * ``True`` - same as 'rollback', this is here for backwards compatibility. * ``"commit"`` - call commit() on the connection, to release locks and transaction resources. A commit here may be desirable for databases that cache query plans if a commit is emitted, such as Microsoft SQL Server. However, this value is more dangerous than 'rollback' because any data changes present on the transaction are committed unconditionally. * ``None`` - don't do anything on the connection. This setting should generally only be made on a database that has no transaction support at all, namely MySQL MyISAM; when used on this backend, performance can be improved as the "rollback" call is still expensive on MySQL. It is **strongly recommended** that this setting not be used for transaction-supporting databases in conjunction with a persistent pool such as :class:`.QueuePool`, as it opens the possibility for connections still in a transaction to be idle in the pool. The setting may be appropriate in the case of :class:`.NullPool` or special circumstances where the connection pool in use is not being used to maintain connection lifecycle. * ``False`` - same as None, this is here for backwards compatibility. :param events: a list of 2-tuples, each of the form ``(callable, target)`` which will be passed to :func:`.event.listen` upon construction. Provided here so that event listeners can be assigned via :func:`_sa.create_engine` before dialect-level listeners are applied. :param listeners: A list of :class:`.PoolListener`-like objects or dictionaries of callables that receive events when DB-API connections are created, checked out and checked in to the pool. :param dialect: a :class:`.Dialect` that will handle the job of calling rollback(), close(), or commit() on DBAPI connections. If omitted, a built-in "stub" dialect is used. Applications that make use of :func:`_sa.create_engine` should not use this parameter as it is handled by the engine creation strategy. .. versionadded:: 1.1 - ``dialect`` is now a public parameter to the :class:`_pool.Pool`. :param pre_ping: if True, the pool will emit a "ping" (typically "SELECT 1", but is dialect-specific) on the connection upon checkout, to test if the connection is alive or not. If not, the connection is transparently re-connected and upon success, all other pooled connections established prior to that timestamp are invalidated. Requires that a dialect is passed as well to interpret the disconnection error. .. versionadded:: 1.2 N)echoflagr r T)noneNFr reset_on_returnF)resolve_symbol_names)only_propagate)logging_name_orig_logging_namer instance_loggerr local_threadconns_creator_recycle_invalidate_time_use_threadlocal _pre_pingr symbolparse_user_argumentr r r _reset_on_returnechodispatch_update_dialectr listenadd_listener)r creatorrecyclerA r+ r4 r1 r, eventsdialectpre_ping _dispatchfntargetls r __init__z Pool.__init__? sp H +:FFD 7 7&*D#D40000%O-- ! /! $ ? ?T 2111xj !& !@ ! ! CM!!)E!BBB $#DM /$ / / FT62.... % % %!!!$$$$ % % % %r c | j d S Nr9 )__dict__r s r r9 z Pool._creator s }Z((r c N || j d<