Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/sqlalchemy/pool/__pycache__/base.cpython-39.pyc
Ðазад
a _�h�� � @ s� d Z ddlmZ ddlZddlZddlmZ ddlmZ ddlmZ ddlm Z dd lm Z dd l mZ e �d�Z e �d�Ze �d �ZG dd� de�ZG dd� de j�ZG dd� de�Zddd�Ze� ZG dd� de�ZdS )z'Base constructs for connection pools. � )�dequeN� )�event)�exc)� interfaces)�log)�util)� threading�reset_rollback�reset_commit� reset_nonec @ s0 e Zd ZdZdd� Zdd� Zdd� Zdd � Zd S )�_ConnDialectz�partial 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 C s |� � d S �N)�rollback��self�dbapi_connection� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/sqlalchemy/pool/base.py�do_rollback) s z_ConnDialect.do_rollbackc C s |� � d S r )�commitr r r r � do_commit, s z_ConnDialect.do_commitc C s |� � d S r )�closer r r r �do_close/ s z_ConnDialect.do_closec C s t d��d S )NzJThe ping feature requires that a dialect is passed to the connection pool.��NotImplementedErrorr r r r �do_ping2 s �z_ConnDialect.do_pingN)�__name__� __module__�__qualname__�__doc__r r r r r r r r r s r c @ s� e Zd ZdZe� Zejddd�d*d d ��Ze dd� �Z e jd d� �Z dd� Zdd� Z e�dd�dd� �Zdd� Zdd� Zd+dd�Zdd� Zdd� Zd d!� Zd"d#� Zd$d%� Zd&d'� Zd(d)� 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� listeners���NFTc C s� |r| | _ | _nd| _tj| |d� t�� | _|| _|| _d| _ || _ | | _tj j|tddgtg d�tdgidd d �| _|| _|r�| jj|d d� | r�| | _|r�|D ]\}} t�| | |� q�|r�|D ]}| �|� q�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)Zechoflagr r T)�noneNFr �reset_on_returnF)Zresolve_symbol_names)Zonly_propagate)�logging_nameZ_orig_logging_namer Zinstance_loggerr �local�_threadconns�_creator�_recycle�_invalidate_time�_use_threadlocal� _pre_pingr �symbolZparse_user_argumentr r r �_reset_on_return�echo�dispatch�_update�_dialectr �listen�add_listener)r �creator�recycler2 r# r( r'