Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
impl.cpython-313.pyc246 linesDownload Raw Back to __pycache__
1�

2��j�M����SrSSKJr SSKrSSKrSSKrSSKJr SSKJr SSKJr SSKJ	r	 SSKJ3r4 SS	KJr SS5KJr SSKJ
r
 SSKrSS
KJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr \R(aSSK J!r! "SS\5r""SS\"5r#"S S!\#5r$"S"S#\5r%"S$S%\5r&"S&S'\5r'"S(S)\5r(g)*zPool implementation classes.�)�annotationsN)�Any)�cast)�List)�Optional)�Set)�Type)�
TYPE_CHECKING)�Union�)�_AsyncConnDialect)�_ConnectionFairy��_ConnectionRecord)�_CreatorFnType)�_CreatorWRecFnType)�ConnectionPoolEntry)�Pool)�PoolProxiedConnection�)�exc)�util)�chop_traceback)�queue)�Literal)�DBAPIConnectionc���\rSrSr%SrSr\RrS\	S'S\	S'SSSjjr6SS	jrSS7jrSSjr
SSjrSS
jrSSjrSSjrS SjrS!SjrS SjrS SjrS SjrSrg)"�	QueuePool�+aA :class:`_pool.Pool`8that imposes a limit on the number of open connections.9 10:class:`.QueuePool` is the default pooling implementation used for11all :class:`_engine.Engine` objects other than SQLite with a ``:memory:``12database.13 14The :class:`.QueuePool` class **is not compatible** with asyncio and15:func:`_asyncio.create_async_engine`.  The16:class:`.AsyncAdaptedQueuePool` class is used automatically when17using :func:`_asyncio.create_async_engine`, if no other kind of pool18is specified.19 20.. seealso::21 22    :class:`.AsyncAdaptedQueuePool`23 24F�1Type[sqla_queue.QueueCommon[ConnectionPoolEntry]]�_queue_classz+sqla_queue.QueueCommon[ConnectionPoolEntry]�_poolc���[R"X40UD6 URX%S9UlSU-25UlUS:XaSOUUlX@l[R"5Ul	g)a�26Construct a QueuePool.27 28:param creator: a callable function that returns a DB-API29  connection object, same as that of :paramref:`_pool.Pool.creator`.30 31:param pool_size: The size of the pool to be maintained,32  defaults to 5. This is the largest number of connections that33  will be kept persistently in the pool. Note that the pool34  begins with no connections; once this number of connections35  is requested, that number of connections will remain.36  ``pool_size`` can be set to 0 to indicate no size limit; to37  disable pooling, use a :class:`~sqlalchemy.pool.NullPool`38  instead.39 40:param max_overflow: The maximum overflow size of the41  pool. When the number of checked-out connections reaches the42  size set in pool_size, additional connections will be43  returned up to this limit. When those additional connections44  are returned to the pool, they are disconnected and45  discarded. It follows then that the total number of46  simultaneous connections the pool will allow is pool_size +47  `max_overflow`, and the total number of "sleeping"48  connections the pool will allow is pool_size. `max_overflow`49  can be set to -1 to indicate no overflow limit; no limit50  will be placed on the total number of concurrent51  connections. Defaults to 10.52 53:param timeout: The number of seconds to wait before giving up54  on returning a connection. Defaults to 30.0. This can be a float55  but is subject to the limitations of Python time functions which56  may not be reliable in the tens of milliseconds.57 58:param use_lifo: use LIFO (last-in-first-out) when retrieving59  connections instead of FIFO (first-in-first-out). Using LIFO, a60  server-side timeout scheme can reduce the number of connections used61  during non-peak periods of use.   When planning for server-side62  timeouts, ensure that a recycle or pre-ping strategy is in use to63  gracefully handle stale connections.64 65  .. versionadded:: 1.366 67  .. seealso::68 69    :ref:`pool_use_lifo`70 71    :ref:`pool_disconnects`72 73:param \**kw: Other keyword arguments including74  :paramref:`_pool.Pool.recycle`, :paramref:`_pool.Pool.echo`,75  :paramref:`_pool.Pool.reset_on_return` and others are passed to the76  :class:`_pool.Pool` constructor.77 78)�use_lifor�����N)79r�__init__r!r"�	_overflow�
_max_overflow�_timeout�	threading�Lock�_overflow_lock)�self�creator�	pool_size�max_overflow�timeoutr$�kws       �ZD:\code\apps\devtools\python\user_packages\Python313\site-packages\sqlalchemy/pool/impl.pyr&�QueuePool.__init__GsZ��@	
�
�
�d�*�r�*��&�&�y�&�D��80��Y����#,��>�R�|����
�'�n�n�.���c���URRUS5 g![Ra9 UR	5 UR5 g!UR5 f=ff=f�NF)r"�put�81sqla_queue�Full�close�
_dec_overflow�r-�records  r3�_do_return_conn�QueuePool._do_return_conn�sS��	%��J�J�N�N�6�5�)�����	%�
%������"�"�$���"�"�$��		%�s ��A,�A�A,�A(�(A,c���URS:�nU=(a URUR:�nURRX R5$![82Ra Of=fU(arURUR:�aXU(dUR5$[R"SUR5UR5UR4-SS9eUR5(aVUR5$! [R"5 UR!5 SSS5 e!,(df   e=f=fUR5$)Nr%zSQueuePool limit of size %d overflow %d reached, connection timed out, timeout %0.2f�3o7r)�code)r(r'r"�getr)r9�Empty�_do_getr�TimeoutError�size�overflow�
_inc_overflow�_create_connectionr�safe_reraiser<)r-�use_overflow�waits   r3rF�QueuePool._do_get�s&���)�)�B�.���D����$�2D�2D� D��	��:�:�>�>�$�
�
�6�6�����	�
�		��83�D�N�N�d�.@�.@�@���|�|�~�%��&�&�:��y�y�{�D�M�M�O�T�]�]�C�D� �	�������
��.�.�0�0��
��&�&�(��&�&�(�)��)�(����<�<�>�!s5�$A�A/�.A/�D�E�(E�9	E�84E	�Ec��URS:XaU=RS-
slgUR URUR:aU=RS-
slSSS5 gSSS5 g!,(df   g=f)Nr%rTF�r(r'r,�r-s r3rJ�QueuePool._inc_overflow�sf������#��N�N�a��N��
�
 �
 ��~�~�� 2� 2�2����!�#���!�
 �85�!�
 �
 �s�1A7�-A7�786Bc���URS:XaU=RS-slgUR U=RS-slSSS5 g!,(df   g=f)Nr%rTrQrRs r3r<�QueuePool._dec_overflow�sG������#��N�N�a��N��
�
 �
 ��N�N�a��N��!�
 �
 �s�A�87A!c��URRS5 URURURR88URURURRURURURURURURURS9$)N�Pool recreating)r/r0�pre_pingr$r1�recycle�echo�logging_name�reset_on_return�	_dispatch�dialect)�logger�info�	__class__�_creatorr"�maxsizer(�	_pre_pingr$r)�_recyclerZ�_orig_logging_name�_reset_on_return�dispatch�_dialectrRs r3�recreate�QueuePool.recreate�s��������*�+��~�~��M�M��j�j�(�(��+�+��^�^��Z�Z�(�(��M�M��M�M�����0�0� �1�1��m�m��M�M��
89�
	90r5c��URRS5nUR5 M.![Ra Of=fSUR5-91UlURRSUR55 g)NFrzPool disposed. %s)92r"rDr;r9rErHr'r_r`�status�r-�conns  r3�dispose�QueuePool.dispose�sr���
��z�z�~�~�e�,���93�94�����#�#�
��
���T�Y�Y�[���������,�d�k�k�m�<s�+0�A�Ac��SUR5UR5UR5UR54-$)Nz_Pool size: %d  Connections in pool: %d Current Overflow: %d Current Checked out connections: %d)rH�	checkedinrI�95checkedoutrRs r3rm�QueuePool.status�s>��
��	�	����� ��
�
�����!�	�
�96	97r5c�.�URR$�N)r"rcrRs r3rH�QueuePool.size�s���z�z�!�!�!r5c��UR$rw)r)rRs r3r1�QueuePool.timeout�s���}�}�r5c�6�URR5$rw)r"�qsizerRs r3rs�QueuePool.checkedin�s���z�z���!�!r5c�T�URR(aUR$S$)Nr)r"rcr'rRs r3rI�QueuePool.overflow�s��!%���!3�!3�t�~�~�:��:r5c�~�URRURR5-98UR-$rw)r"rcr|r'rRs r3rt�QueuePool.checkedout�s-���z�z�!�!�D�J�J�$4�$4�$6�6����G�Gr5)r(r'r,r"r)N)��99g>@F)r.�)Union[_CreatorFnType, _CreatorWRecFnType]r/�intr0r�r1�floatr$�boolr2r�r>r�return�None�r�r)r�r�)r�z
Literal[True])r�r�r�r��r��str)r�r�)r�r�)�__name__�100__module__�__qualname__�__firstlineno__�__doc__�_is_asyncior9�Queuer!�__annotations__r&r?rFrJr<rjrprmrHr1rsrIrt�__static_attributes__�r5r3rr+s����&�K�	����C��7�6�101����
E/�:�E/��E/��	E/�102�E/��
E/��E/�N%�"�@	��103�"	=�104�"��"�;�Hr5rc�N�\rSrSr%SrSr\RrS\	S'\105"5rSrg)�AsyncAdaptedQueuePoolia�An asyncio-compatible version of :class:`.QueuePool`.106 107This pool is used by default when using :class:`.AsyncEngine` engines that108were generated from :func:`_asyncio.create_async_engine`.   It uses an109asyncio-compatible queue implementation that does not use110``threading.Lock``.111 112The arguments and operation of :class:`.AsyncAdaptedQueuePool` are113otherwise identical to that of :class:`.QueuePool`.114 115Tr r!r�N)
r�r�r�r�r�r�r9�AsyncAdaptedQueuer!r�r
rir�r�r5r3r�r�s.��116��K��$�$��C��!�"�Hr5r�c�,�\rSrSr\R117rSrg)�FallbackAsyncAdaptedQueuePoolir�N)r�r�r�r�r9�FallbackAsyncAdaptedQueuer!r�r�r5r3r�r�s
���7�7�Lr5r�c�J�\rSrSrSrS118SjrSSjrSSjrS
SjrSSjr	Sr119g	)�NullPoolia�A Pool which does not pool connections.120 121Instead it literally opens and closes the underlying DB-API connection122per each connection open/close.123 124Reconnect-related functions such as ``recycle`` and connection125invalidation are not supported by this Pool implementation, since126no connections are held persistently.127 128The :class:`.NullPool` class **is compatible** with asyncio and129:func:`_asyncio.create_async_engine`.130 131c��g)Nr�r�rRs r3rm�NullPool.status+s��r5c�$�UR5 grw)r;r=s  r3r?�NullPool._do_return_conn.s�����r5c�"�UR5$rw)rKrRs r3rF�NullPool._do_get1s���&�&�(�(r5c��URRS5 URURURUR132URURURURURS9$)NrW)rYrZr[r\rXr]r^)r_r`rarbrerZrfrgrdrhrirRs r3rj�NullPool.recreate4sg�������*�+��~�~��M�M��M�M�����0�0� �1�1��^�^��m�m��M�M��	133�		134r5c��grwr�rRs r3rp�NullPool.disposeB���r5r�Nr�r�r�)r�r�r�)r�r�r�r�r�rmr?rFrjrpr�r�r5r3r�r�s �����)�135�
r5r�c��\rSrSrSrSrSSSjjrSSjrSSjrSSjr	SSjr136SS	jrSS137jrSSjr
SSjrS
rg)�SingletonThreadPooliFa�A Pool that maintains one connection per thread.138 139Maintains one connection per each thread, never moving a connection to a140thread other than the one which it was created in.141 142.. warning::  the :class:`.SingletonThreadPool` will call ``.close()``143   on arbitrary connections that exist beyond the size setting of144   ``pool_size``, e.g. if more unique **thread identities**145   than what ``pool_size`` states are used.   This cleanup is146   non-deterministic and not sensitive to whether or not the connections147   linked to those thread identities are currently in use.148 149   :class:`.SingletonThreadPool` may be improved in a future release,150   however in its current status it is generally used only for test151   scenarios using a SQLite ``:memory:`` database and is not recommended152   for production use.153 154The :class:`.SingletonThreadPool` class **is not compatible** with asyncio155and :func:`_asyncio.create_async_engine`.156 157 158Options are the same as those of :class:`_pool.Pool`, as well as:159 160:param pool_size: The number of threads in which to maintain connections161    at once.  Defaults to five.162 163:class:`.SingletonThreadPool` is used by the SQLite dialect164automatically when a memory-based database is used.165See :ref:`sqlite_toplevel`.166 167Fc���[R"X40UD6 [R"5Ul[R"5Ul[
5UlX lgrw)	rr&r*�local�_conn�_fairy�set�168_all_connsrH)r-r.r/r2s    r3r&�SingletonThreadPool.__init__is?��	
�
�
�d�*�r�*��_�_�&��169��o�o�'���47�E����	r5c��URRS5 URURURUR170URURURURURURS9	$)NrW)r/rYrZrXr[r\r]r^)r_r`rarbrHrerZrdrfrgrhrirRs r3rj�SingletonThreadPool.recreateusn�������*�+��~�~��M�M��i�i��M�M�����^�^��0�0� �1�1��m�m��M�M��171172�173	174r5c��[URS5(aeURUlURUlg)N�current)�hasattrr�r�r�)r-�other_singleton_pools  r3�_transfer_from�"SingletonThreadPool._transfer_from�s8��175�/�6�6�	�B�B�B�B�)�/�/��176�.�9�9��r5c��URHnUR5 M URR5 g![a M@f=f)zDispose of this pool.N)r�r;�	Exception�clearrns  r3rp�SingletonThreadPool.dispose�sH���O�O�D�
��177�178��$�	
��������
��
�s�A�179A�
Ac���[UR5UR:�aPURR5nUR	5 [UR5UR:�aMOggrw)�lenr�rH�popr;�r-�cs  r3�_cleanup�SingletonThreadPool._cleanup�sI���$�/�/�"�d�i�i�/����#�#�%�A�
�G�G�I��$�/�/�"�d�i�i�/r5c�H�S[U5[UR54-$)Nz"SingletonThreadPool id:%d size: %d)�idr�r�rRs r3rm�SingletonThreadPool.status�s'��3��t�H����� �7180�181�	182r5c�>�UR?g![a gf=frw)r�r��AttributeErrorr=s  r3r?�#SingletonThreadPool._do_return_conn�s#��	����#���	��	�s��183�c���[(a)[[URR	55nOURR	5nU(aU$UR
5n[R"U5URl[UR5UR:�aUR5 URRU5 U$![184a N�f=frw)r185rrr�r�r�rK�weakref�refr�r�rHr��addr�s  r3rF�SingletonThreadPool._do_get�s���	��}��,�d�j�j�.@�.@�.B�C���J�J�&�&�(������
�#�#�%��$�[�[��^��186�187���t����4�9�9�,��M�M�O������A������	��	�s�AC�188C,�+C,c���[[URR55nUbUR	5$[R"XR5$![189a N,f=frw)rrr�r��_checkout_existingr��	_checkout�r-�recs  r3�connect�SingletonThreadPool.connect�sg��	0��'����)<�)<�)>�?�C����-�-�/�/�� �)�)�$���<�<��
�	��	�s�(A�190A+�*A+)r�r�r�rHN)r�)r.r�r/r�r2r)r�r�)r�r�r�r�r�r�r�r�)r�r)r�r�r�r�r�r�r&rjr�rpr�rmr?rFr�r�r�r5r3r�r�Fsm���@�K�191�192�:�193��194��	195�196�:�$7�:�	
�:� ��197198���"=r5r�c��\rSrSrSr\RS
Sj5rSSjrSSjr	SSjr199SSjrSSjrSS	jr
SS200jrSrg)�201StaticPooli�afA Pool of exactly one connection, used for all requests.202 203Reconnect-related functions such as ``recycle`` and connection204invalidation (which is also used to support auto-reconnect) are only205partially supported right now and may not yield good results.206 207The :class:`.StaticPool` class **is compatible** with asyncio and208:func:`_asyncio.create_async_engine`.209 210c��[U5$rwrrRs r3�211connection�StaticPool.connection�s
�� ��&�&r5c��g)Nr�r�rRs r3rm�StaticPool.status�s��r5c��SUR;a@URRb(URR5 URS	ggg�Nr�)�__dict__r��dbapi_connectionr;rRs r3rp�StaticPool.dispose�sD���D�M�M�)����0�0�<��O�O�!�!�#��
�
�l�+�=�
*r5c��URRS5 URURURUR212URURURURURS9$)NrW)r.rYr\rXrZr[r]r^)r_r`rarbrergrdrZrfrhrirRs r3rj�StaticPool.recreate�sg�������*�+��~�~��M�M��M�M� �1�1��^�^�����0�0��m�m��M�M��	213�		214r5c�"^�SU4SjjnX lg)Nc�>>�TRRnUceU$rw)r�r�)r�ro�other_static_pools  �r3r.�*StaticPool._transfer_from.<locals>.creator�s%���$�/�/�@�@�D��#�#�#��Kr5)r�rr�r��_invoke_creator)r-r�r.s ` r3r��StaticPool._transfer_from�s���	�215 '�r5c��[5erw)�NotImplementedErrorrRs r3rK�StaticPool._create_connection�s��!�#�#r5c��grwr�r=s  r3r?�StaticPool._do_return_conn�r�r5c�z�URnUR5(aURS	URnU$r�)r��_is_hard_or_soft_invalidatedr�r�s  r3rF�StaticPool._do_gets4���o�o���+�+�-�-��
�
�l�+��/�/�C��216r5r�N)r�rr�r�)r�r�)r�r�r�r�r�r�)r�r�r�r�r�r�memoized_propertyr�rmrprjr�rKr?rFr�r�r5r3r�r��sD��	�217���'��'��,�218�'�$�
�r5r�c�j�\rSrSr%SrS\S'S\S'SSjrSSjrSS	jrSS219jr	SSjr220SSjrS
rg)�
AssertionPooli221aaA :class:`_pool.Pool` that allows at most one checked out connection at222any given time.223 224This will raise an exception if more than one connection is checked out225at a time.  Useful for debugging code that is using more connections226than desired.227 228The :class:`.AssertionPool` class **is compatible** with asyncio and229:func:`_asyncio.create_async_engine`.230 231zOptional[ConnectionPoolEntry]r�zOptional[List[str]]�_checkout_tracebackc��SUlSUlURSS5UlSUl[232R"U/UQ70UD6 g)NF�store_tracebackT)r��_checked_outr��_store_tracebackr�rr&)r-�argsr2s   r3r&�AssertionPool.__init__sC����233�!��� "���'8�$� ?���#'�� ��
�
�d�(�T�(�R�(r5c��g)Nr�r�rRs r3rm�AssertionPool.status!s��r5c�j�UR(d[S5eSUlXRLdeg)Nzconnection is not checked outF)r��AssertionErrorr�r=s  r3r?�AssertionPool._do_return_conn$s/��� � � �!@�A�A�!������#�#�#r5c�j�SUlUR(aURR5 ggr7)r�r�r;rRs r3rp�AssertionPool.dispose*s&��!����:�:��J�J����r5c��URRS5 URURURUR234URURURURURS9$)NrW)rZrXrYr\r[r]r^)r_r`rarbrZrdrergrfrhrirRs r3rj�AssertionPool.recreate/sg�������*�+��~�~��M�M�����^�^��M�M� �1�1��0�0��m�m��M�M��	235�		236r5c�~�UR(aIUR(a(SSR[UR55-nOSn[	SU-5eUR237(dUR
5UlSUlUR(a[R"5UlUR238$)Nz at:239%s�z!connection is already checked outT)240r�r��joinrrr�rKr��	traceback�format_stack)r-�suffixs  r3rF�AssertionPool._do_get<s�������'�'�#�b�g�g�"�4�#;�#;�<�'����� �!D�v�!M�N�N��z�z��0�0�2�D�J� ���� � �'0�'=�'=�'?�D�$��z�z�r5)r�r�r�r�N)r�rr2rr�r�r�)r�r�r�)
r�r�r�r�r�r�r&rmr?rprjrFr�r�r5r3r�r�241s3��242�)�(�,�,�)��$��243244�r5r�))r��245__future__rr*r
�typingrrrrrr	r246rr��baser
rrrrrrrrrrrrr9�util.typingr�engine.interfacesrrr�r�r�r�r�r�r�r5r3�<module>rs���#�"���
������� ���#�"�#� �$�%��'���!�&�!�	���3�UH��UH�p#�I�#�*8�$9�8�'
�t�'
�T@=�$�@=�F>��>�BB�D�Br5
codekingpro/portable-devtools · Team Ai