Q-В d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlmZ dd lm Z dd
l m
Z
ddl mZ ddl m
Z
G d
de Z G d de Z G d de Z G d de Z G d de ZdS )zPool implementation classes.
N )_ConnectionFairy_ConnectionRecord)Pool )exc)util)chop_traceback)queue) threadingc j e Zd ZdZ ddZd Zd Zd Zd
Zd Z d Z
d
Zd Zd Z
d Zd Zd ZdS ) QueuePoolzA :class:`_pool.Pool`
that imposes a limit on the number of open connections.
:class:`.QueuePool` is the default pooling implementation used for
all :class:`_engine.Engine` objects, unless the SQLite dialect is in use.
Fc t j | |fi | t j || | _ d|z
| _ || _ || _ t j | _
dS )a=
Construct a QueuePool.
:param creator: a callable function that returns a DB-API
connection object, same as that of :paramref:`_pool.Pool.creator`.
:param pool_size: The size of the pool to be maintained,
defaults to 5. This is the largest number of connections that
will be kept persistently in the pool. Note that the pool
begins with no connections; once this number of connections
is requested, that number of connections will remain.
``pool_size`` can be set to 0 to indicate no size limit; to
disable pooling, use a :class:`~sqlalchemy.pool.NullPool`
instead.
:param max_overflow: The maximum overflow size of the
pool. When the number of checked-out connections reaches the
size set in pool_size, additional connections will be
returned up to this limit. When those additional connections
are returned to the pool, they are disconnected and
discarded. It follows then that the total number of
simultaneous connections the pool will allow is pool_size +
`max_overflow`, and the total number of "sleeping"
connections the pool will allow is pool_size. `max_overflow`
can be set to -1 to indicate no overflow limit; no limit
will be placed on the total number of concurrent
connections. Defaults to 10.
:param timeout: The number of seconds to wait before giving up
on returning a connection. Defaults to 30.
:param use_lifo: use LIFO (last-in-first-out) when retrieving
connections instead of FIFO (first-in-first-out). Using LIFO, a
server-side timeout scheme can reduce the number of connections used
during non-peak periods of use. When planning for server-side
timeouts, ensure that a recycle or pre-ping strategy is in use to
gracefully handle stale connections.
.. versionadded:: 1.3
.. seealso::
:ref:`pool_use_lifo`
:ref:`pool_disconnects`
:param \**kw: Other keyword arguments including
:paramref:`_pool.Pool.recycle`, :paramref:`_pool.Pool.echo`,
:paramref:`_pool.Pool.reset_on_return` and others are passed to the
:class:`_pool.Pool` constructor.
)use_lifor N)r __init__
sqla_queueQueue_pool _overflow
_max_overflow_timeoutr
Lock_overflow_lock)selfcreator pool_sizemax_overflowtimeoutr kws h/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib64/python3.11/site-packages/sqlalchemy/pool/impl.pyr zQueuePool.__init__$ sf z
dG**r***%i(CCC
Y)
'n.. c | j |d d S # t j $ rF | | Y d S # | w xY ww xY wNF)r putr Fullclose
_dec_overflowr conns r$ _do_return_connzQueuePool._do_return_connh s %JNN4''''' % % %
%
""$$$$$$""$$$$ %s A4AA4A00A4c | j dk } |o| j | j k }| j || j S # t
j $ r Y nw xY w|rk| j | j k r[|s| S t j d|
| | j fz d | r_ |
S # t j 5 | d d d n# 1 swxY w Y Y d S Y d S xY w| S )NzPQueuePool limit of size %d overflow %d reached, connection timed out, timeout %d3o7r)code)r r r getr r Empty_do_getr TimeoutErrorsizeoverflow
_inc_overflow_create_connectionr
safe_reraiser+ )r use_overflowwaits r$ r5 zQueuePool._do_getq s )B. HDNd6H$HD:>>$
666
D
DNd.@@@
||~~%&7yy{{DMMOOT]CD "
)..000
)&(( ) )&&((() ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) <<>>!s? 1? AAC* *D1?D D1 D$ $D1'D$ (D1c | j dk r| xj dz
c_ dS | j 5 | j | j k r| xj dz
c_ d d d dS d d d dS # 1 swxY w Y d S )Nr0 r TFr r r r s r$ r9 zQueuePool._inc_overflow s ##NNaNN4
~ 222!#
s "A"A""A&)A&c | j dk r| xj dz c_ dS | j 5 | xj dz c_ d d d dS # 1 swxY w Y d S )Nr0 r Tr? r@ s r$ r+ zQueuePool._dec_overflow s ##NNaNN4
NNaNN s AAAc | j d | | j | j j | j | j | j j | j | j
| j | j | j
| j | j | j
S )NPool recreating)r r! pre_pingr r" recycleechologging_nameuse_threadlocalreset_on_return _dispatchdialect)loggerinfo __class___creatorr maxsizer _pre_pingr r _recyclerF _orig_logging_name_use_threadlocal_reset_on_returndispatch_dialectr@ s r$ recreatezQueuePool.recreate s *+++~~Mj(+^Z(MM0 1 1mM
r% c & | j d }| n# t j $ r Y nw xY wFd| z
| _ | j d| d S )NTFr zPool disposed. %s)
r r3 r* r r4 r7 r rL rM statusr, s r$ disposezQueuePool.dispose s
z~~e,,
#
TYY[[,dkkmm<<<<