Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/util/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/util/__pycache__/queue.cpython-311.pyc

�

�܋f����dZddlmZddlmZddlmZgd�ZGd�de��Z	Gd	�d
e��Z
Gd�d��Zd
S)a�An adaptation of Py2.3/2.4's Queue module which supports reentrant
behavior, using RLock instead of Lock for its mutex object.  The
Queue object is used exclusively by the sqlalchemy.pool.QueuePool
class.

This is to support the connection pool's usage of weakref callbacks to return
connections to the underlying Queue, which can in extremely
rare cases be invoked within the ``get()`` method of the Queue itself,
producing a ``put()`` inside the ``get()`` and therefore a reentrant
condition.

�)�deque)�time�)�	threading)�Empty�Full�Queuec��eZdZdZdS)rz4Exception raised by Queue.get(block=0)/get_nowait().N��__name__�
__module__�__qualname__�__doc__���L/opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/util/queue.pyrr�������:�:��Drrc��eZdZdZdS)rz4Exception raised by Queue.put(block=0)/put_nowait().Nrrrrrr$rrrc�h�eZdZdd�Zd�Zd�Zd�Zdd	�Zd
�Zdd�Z	d�Z
d
�Zd�Zd�Z
d�Zd�Zd�ZdS)r	rFc���|�|��tj��|_tj|j��|_tj|j��|_||_dS)z�Initialize a queue object with a given maximum size.

        If `maxsize` is <= 0, the queue size is infinite.

        If `use_lifo` is True, this Queue acts like a Stack (LIFO).
        N)�_initr�RLock�mutex�	Condition�	not_empty�not_full�use_lifo)�self�maxsizers   r�__init__zQueue.__init__+s^��	
�
�
�7����
�_�&�&��
�#�,�T�Z�8�8���"�+�D�J�7�7��
� ��
�
�
rc��|j���|���}|j���|S)z9Return the approximate size of the queue (not reliable!).)r�acquire�_qsize�release�r�ns  r�qsizezQueue.qsizeBs>��	
�
�������K�K�M�M���
�������rc��|j���|���}|j���|S)zKReturn True if the queue is empty, False otherwise (not
        reliable!).)rr"�_emptyr$r%s  r�emptyzQueue.emptyJs>��	
�
�������K�K�M�M���
�������rc��|j���|���}|j���|S)zJReturn True if the queue is full, False otherwise (not
        reliable!).)rr"�_fullr$r%s  r�fullz
Queue.fullSs>��	
�
�������J�J�L�L���
�������rTNc���|j���	|s|���rt�n�|�B|���r-|j���|����-n�|dkrtd���t
��|z}|���rL|t
��z
}|dkrt�|j�|��|����L|�|��|j�	��|j�
��dS#|j�
��wxYw)aPut an item into the queue.

        If optional args `block` is True and `timeout` is None (the
        default), block if necessary until a free slot is
        available. If `timeout` is a positive number, it blocks at
        most `timeout` seconds and raises the ``Full`` exception if no
        free slot was available within that time.  Otherwise (`block`
        is false), put an item on the queue if a free slot is
        immediately available, else raise the ``Full`` exception
        (`timeout` is ignored in that case).
        Nr�#'timeout' must be a positive number�)rr"r,r�wait�
ValueError�_time�_putr�notifyr$)r�item�block�timeout�endtime�	remainings      r�putz	Queue.put\sR��	
�
������	$��
2��:�:�<�<���J�����j�j�l�l�)��M�&�&�(�(�(��j�j�l�l�)���Q�;�;�$�%J�K�K�K��'�'�G�+���j�j�l�l�2� '�%�'�'� 1�I� �C�'�'�"�
��M�&�&�y�1�1�1�	�j�j�l�l�2�

�I�I�d�O�O�O��N�!�!�#�#�#��M�!�!�#�#�#�#�#��D�M�!�!�#�#�#�#���s�DE�E'c�.�|�|d��S)z�Put an item into the queue without blocking.

        Only enqueue the item if a free slot is immediately available.
        Otherwise raise the ``Full`` exception.
        F)r;�rr6s  r�
put_nowaitzQueue.put_nowaits���x�x��e�$�$�$rc���|j���	|s|���rt�n�|�B|���r-|j���|����-n�|dkrtd���t
��|z}|���rL|t
��z
}|dkrt�|j�|��|����L|���}|j�	��||j�
��S#|j�
��wxYw)aRemove and return an item from the queue.

        If optional args `block` is True and `timeout` is None (the
        default), block if necessary until an item is available. If
        `timeout` is a positive number, it blocks at most `timeout`
        seconds and raises the ``Empty`` exception if no item was
        available within that time.  Otherwise (`block` is false),
        return an item if one is immediately available, else raise the
        ``Empty`` exception (`timeout` is ignored in that case).
        Nrr/r0)rr"r)rr1r2r3�_getrr5r$)rr7r8r9r:r6s      r�getz	Queue.get�sP��	
���� � � �	%��
3��;�;�=�=� ��K� ����k�k�m�m�*��N�'�'�)�)�)��k�k�m�m�*���Q�;�;�$�%J�K�K�K��'�'�G�+���k�k�m�m�3� '�%�'�'� 1�I� �C�'�'�#���N�'�'�	�2�2�2�	�k�k�m�m�3�
�9�9�;�;�D��M� � �"�"�"���N�"�"�$�$�$�$��D�N�"�"�$�$�$�$���s�DE�E&c�,�|�d��S)z�Remove and return an item from the queue without blocking.

        Only get an item if one is immediately available. Otherwise
        raise the ``Empty`` exception.
        F)rA�rs r�
get_nowaitzQueue.get_nowait�s���x�x����rc�:�||_t��|_dS�N)rr�queue)rrs  rrzQueue._init�s������W�W��
�
�
rc�*�t|j��SrF)�lenrGrCs rr#zQueue._qsize�s���4�:���rc��|jSrF)rGrCs rr)zQueue._empty�s���:�~�rc�R�|jdkot|j��|jkS)Nr)rrIrGrCs rr,zQueue._full�s#���|�a��C�C��
�O�O�t�|�$C�Crc�:�|j�|��dSrF)rG�appendr=s  rr4z
Queue._put�s���
���$�����rc�t�|jr|j���S|j���SrF)rrG�pop�popleftrCs rr@z
Queue._get�s4���=�	(��:�>�>�#�#�#��:�%�%�'�'�'r)rF)TN)rr
rr r'r*r-r;r>rArDrr#r)r,r4r@rrrr	r	*s�������!�!�!�!�.���������!$�!$�!$�!$�F%�%�%� %� %� %� %�D������������D�D�D� � � �(�(�(�(�(rr	N)r�collectionsrrr3�compatr�__all__�	Exceptionrrr	rrr�<module>rUs�����������������������%�
$�
$��	�	�	�	�	�I�	�	�	�	�	�	�	�	�9�	�	�	�g(�g(�g(�g(�g(�g(�g(�g(�g(�g(r

Hacked By AnonymousFox1.0, Coded By AnonymousFox