Team Ai
Datasetpublic

codekingpro/portable-devtools

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

2��j)��b�SrSSKJr SSKrSSKJr SSKrSSKJr SSK	r	SSK	J3r4 SSK	Jr SSK	Jr SS	K	J
r
 SS5K	Jr SSK	Jr SS
KJr SSKJr SSKJr \"S\6S9r/SQr"SS\5r"SS\5r"SS\
\5r"SS\\5r"SS\\5r"SS\\5rg)a�An adaptation of Py2.3/2.4's Queue module which supports reentrant7behavior, using RLock instead of Lock for its mutex object.  The8Queue object is used exclusively by the sqlalchemy.pool.QueuePool9class.10 11This is to support the connection pool's usage of weakref callbacks to return12connections to the underlying Queue, which can in extremely13rare cases be invoked within the ``get()`` method of the Queue itself,14producing a ``put()`` inside the ``get()`` and therefore a reentrant15condition.16 17�)�annotationsN)�deque)�time)�Any)�	Awaitable)�Deque)�Generic)�Optional)�TypeVar�)�await_fallback)�18await_only)�memoized_property�_T)�bound)�Empty�Full�Queuec��\rSrSrSrSrg)r�,z4Exception raised by Queue.get(block=0)/get_nowait().�N��__name__�19__module__�__qualname__�__firstlineno__�__doc__�__static_attributes__r��[D:\code\apps\devtools\python\user_packages\Python313\site-packages\sqlalchemy/util/queue.pyrr,���:�rrc��\rSrSrSrSrg)r�2z4Exception raised by Queue.put(block=0)/put_nowait().rNrrrr rr2r!rrc��\rSrSr%S\S'S\S'SSSjjrSSjrSSjrSS	jrSS20jr	SSSjjr21SS
jrSSSjjrSr
g)�QueueCommon�8�int�maxsize�bool�use_lifoc��g�Nr��selfr(r*s   r �__init__�QueueCommon.__init__<s��#rc��[5er,��NotImplementedError�r.s r �empty�QueueCommon.empty>���!�#�#rc��[5er,r2r4s r �full�QueueCommon.fullAr7rc��[5er,r2r4s r �qsize�QueueCommon.qsizeDr7rc��[5er,r2�r.�items  r �22put_nowait�QueueCommon.put_nowaitGr7rNc��[5er,r2)r.r@�block�timeouts    r �put�QueueCommon.putJs
��"�#�#rc��[5er,r2r4s r �23get_nowait�QueueCommon.get_nowaitOr7rc��[5er,r2)r.rDrEs   r �get�QueueCommon.getRr7rr�rF�r(r'r*r)��returnr)�rQr'�r@rrQ�None�TN�r@rrDr)rE�Optional[float]rQrT�rQr�rDr)rErWrQr)rrrr�__annotations__r/r5r9r<rArFrIrLrrrr r%r%8s^��
�L��N�E�$�$�$�$�HL�$��$�#�$�5D�$�	
�$�24$�$�$rr%c���\rSrSr%S\S'SSSjjrSSjrSSjrSSjrSSS	jjr	SS25jr26SSSjjrSSjrSS
jr
SSjrSSjrSSjrSSjrSSjrSrg)r�Vz	Deque[_T]�queuec���URU5 [R"5Ul[R"UR5Ul[R"UR5UlX lg)z�Initialize a queue object with a given maximum size.27 28If `maxsize` is <= 0, the queue size is infinite.29 30If `use_lifo` is True, this Queue acts like a Stack (LIFO).31N)�_init�	threading�RLock�mutex�	Condition�	not_empty�not_fullr*r-s   r r/�Queue.__init__YsU��	
�32�33�7��34�_�_�&��35�#�,�,�T�Z�Z�8���"�+�+�D�J�J�7��
� �
rc�p�UR UR5sSSS5 $!,(df   g=f)z9Return the approximate size of the queue (not reliable!).N)rb�_qsizer4s r r<�Queue.qsizeps���Z�Z��;�;�=��Z�Z���'�365c�p�UR UR5sSSS5 $!,(df   g=f)zCReturn True if the queue is empty, False otherwise (not37reliable!).N)rb�_emptyr4s r r5�Queue.emptyvs���Z�Z��;�;�=��Z�Z�rjc�p�UR UR5sSSS5 $!,(df   g=f)zBReturn True if the queue is full, False otherwise (not38reliable!).N)rb�_fullr4s r r9�39Queue.full}s���Z�Z��:�:�<��Z�Z�rjNc�|�UR U(dUR5(a[eO�UcGUR5(a1URR5 UR5(aM1O~US:a[	S5e[5U-nUR5(aKU[5-40nUS::a[eURRU5 UR5(aMKUR
U5 URR5 SSS5 g!,(df   g=f)a�Put an item into the queue.41 42If optional args `block` is True and `timeout` is None (the43default), block if necessary until a free slot is44available. If `timeout` is a positive number, it blocks at45most `timeout` seconds and raises the ``Full`` exception if no46free slot was available within that time.  Otherwise (`block`47is false), put an item on the queue if a free slot is48immediately available, else raise the ``Full`` exception49(`timeout` is ignored in that case).50Nr�#'timeout' must be a positive number�)	reror�wait�51ValueError�_time�_putrd�notify)r.r@rDrE�endtime�	remainings      r rF�	Queue.put�s����]�]���:�:�<�<��J� ����j�j�l�l��M�M�&�&�(��j�j�l�l���Q�;�$�%J�K�K��'�G�+���j�j�l�l� '�%�'� 1�I� �C�'�"�52��M�M�&�&�y�1�	�j�j�l�l�53
�I�I�d�O��N�N�!�!�#�#�]�]�s�A+D-�:A=D-�9+D-�-54D;c�&�URUS5$)z�Put an item into the queue without blocking.55 56Only enqueue the item if a free slot is immediately available.57Otherwise raise the ``Full`` exception.58F)rFr?s  r rA�Queue.put_nowait�s���x�x��e�$�$rc�~�UR U(dUR5(a[eO�UcGUR5(a1URR5 UR5(aM1O~US:a[	S5e[5U-nUR5(aKU[5-59nUS::a[eURRU5 UR5(aMKUR
5nURR5 UsSSS5 $!,(df   g=f)a�Remove and return an item from the queue.60 61If optional args `block` is True and `timeout` is None (the62default), block if necessary until an item is available. If63`timeout` is a positive number, it blocks at most `timeout`64seconds and raises the ``Empty`` exception if no item was65available within that time.  Otherwise (`block` is false),66return an item if one is immediately available, else raise the67``Empty`` exception (`timeout` is ignored in that case).68 69Nrrrrs)	rdrlrrtrurv�_getrerx)r.rDrEryrzr@s      r rL�	Queue.get�s����^�^���;�;�=�=��K�!����k�k�m�m��N�N�'�'�)��k�k�m�m���Q�;�$�%J�K�K��'�G�+���k�k�m�m� '�%�'� 1�I� �C�'�#���N�N�'�'�	�2�	�k�k�m�m�70�9�9�;�D��M�M� � �"��%�^�^�s�A+D.�:A=D.�9+D.�.71D<c�$�URS5$)z�Remove and return an item from the queue without blocking.72 73Only get an item if one is immediately available. Otherwise74raise the ``Empty`` exception.75F)rLr4s r rI�Queue.get_nowait�s���x�x���rc�.�Xl[5Ulgr,)r(rr])r.r(s  r r_�Queue._init�s�����W��76rc�,�[UR5$r,)�lenr]r4s r rh�Queue._qsize�s���4�:�:��rc�$�UR(+$r,)r]r4s r rl�Queue._empty�s���:�:�~�rc�r�URS:�=(a" [UR5UR:H$)Nr)r(r�r]r4s r ro�Queue._full�s'���|�|�a��C�C��77�78�O�t�|�|�$C�Crc�:�URRU5 gr,)r]�appendr?s  r rw�79Queue._put�s���80�81���$�rc��UR(aURR5$URR5$r,)r*r]�pop�popleftr4s r r�82Queue._get�s/���=�=��:�:�>�>�#�#��:�:�%�%�'�'r)r(rbrdrer]r*rNrOrRrPrUrVrSrYrX)r(r'rQrT)rrrrrZr/r<r5r9rFrArLrIr_rhrlrorwrrrrr rrVsx����!�.!�!� �HL� $�� $�#� $�5D� $�	
� $�D%��@����D� �(rrc���\rSrSr\R83(a\SSj5rO\"\5rSSSjjr	SSjr84SrSr\
SSj5rSSjrSSS85jjrSSjrSSSjjrS
rg	)�AsyncAdaptedQueue��c��gr,r)�	coroutines r �await_�AsyncAdaptedQueue.await_�s��58rc��X lXlgr,)r*r(r-s   r r/�AsyncAdaptedQueue.__init__�s�� �
��rc�6�URR5$r,)�_queuer5r4s r r5�AsyncAdaptedQueue.empty�����{�{� � �"�"rc�6�URR5$r,)r�r9r4s r r9�AsyncAdaptedQueue.fulls���{�{���!�!rc�6�URR5$r,)r�r<r4s r r<�AsyncAdaptedQueue.qsizer�rc��UR(a [R"URS9nU$[R"URS9nU$)N)r()r*�asyncio�	LifoQueuer(r)r.r]s  r r��AsyncAdaptedQueue._queues?���=�=��%�%�d�l�l�;�E����M�M�$�,�,�7�E��rc��URRU5 g![Ran[	5UeSnAff=fr,)r�rAr��	QueueFullr)r.r@�errs   r rA�AsyncAdaptedQueue.put_nowaits9��	"��K�K�"�"�4�(��� � �	"��&�c�!��	"�s��A�=�ANc�~�U(dURU5$Ub@UR[R"URRU5U55 gURURRU55 g![R[R4an[5UeSnAff=fr,)	rAr�r��wait_forr�rFr��TimeoutErrorr)r.r@rDrEr�s     r rF�AsyncAdaptedQueue.puts�����?�?�4�(�(�	"��"����G�,�,�T�[�[�_�_�T�-B�G�L�M����D�K�K�O�O�D�1�2���!�!�7�#7�#7�8�	"��&�c�!��	"�s�AB�*B�$B<�,B7�7B<c��URR5$![Ran[	5UeSnAff=fr,)r�rIr��86QueueEmptyr)r.r�s  r rI�AsyncAdaptedQueue.get_nowait+s:��	#��;�;�)�)�+�+���!�!�	#��'�s�"��	#�s��A�;�Ac�t�U(dUR5$Ub>UR[R"URR5U55$URURR55$![R[R4an[5UeSnAff=fr,)	rIr�r�r�r�rLr�r�r)r.rDrEr�s    r rL�AsyncAdaptedQueue.get1s�����?�?�$�$�	#��"��{�{��$�$�T�[�[�_�_�%6��@����{�{�4�;�;�?�?�#4�5�5���"�"�G�$8�$8�9�	#��'�s�"��	#�s�AB�(B�$B7�'B2�2B7)r(r*)r�zAwaitable[Any]rQrrNrOrP)rQzasyncio.Queue[_T]rSrUrVrXrY)rrrr�typing�
TYPE_CHECKING�staticmethodr�rr/r5r9r<rr�rArFrIrLrrrr r�r��s���
���	�8�87�8��j�)���#�"�#����� "�HL�"��"�#�"�5D�"�	
�"�#�#�#rr�c�L�\rSrSr\R88(d\"\5rSr	gSr	g)�FallbackAsyncAdaptedQueuei@rN)89rrrrr�r�r�r
r�rrrr r�r�@s������n�-�� rr�)r�90__future__rr��collectionsrr`rrvr�rrrr	r91r�concurrencyr
r�langhelpersrr�__all__�	Exceptionrrr%rr�r�rrr �<module>r�s����#�����
�������'�#�*�
�T����92$��	�I�	�	�9�	�$�'�"�+�$�<W(�K��O�W(�tM#��B��M#�`.� 1�"� 5�.r
codekingpro/portable-devtools · Team Ai