Hacked By AnonymousFox
�
�܋f� � � � d Z ddlmZ ddlmZ ddlmZ g d�Z G d� de� � Z G d � d
e� � Z
G d� 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 � � e Zd ZdZdS )r z4Exception 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.pyr r � � � � � � �:�:��Dr r c � � e Zd ZdZdS )r z4Exception raised by Queue.put(block=0)/put_nowait().Nr r r r r r $ r r r c �h � e Zd Zdd�Zd� Zd� Zd� Zdd �Zd
� Zdd�Z d� Z
d
� Zd� Zd� Z
d� Zd� Zd� ZdS )r r Fc �� � | � |� � t j � � | _ t j | j � � | _ t j | 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�maxsizer s r �__init__zQueue.__init__+ s^ � �
�
�
�7����
�_�&�&��
� #�,�T�Z�8�8��� "�+�D�J�7�7��
� ��
�
�
r c � � | j � � � | � � � }| j � � � |S )z9Return the approximate size of the queue (not reliable!).)r �acquire�_qsize�release�r �ns r �qsizezQueue.qsizeB s>