HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/sqlalchemy/util/__pycache__/queue.cpython-310.pyc
o

���g�'�@s4dZddlmZddlZddlmZddlZddlmZddl	Z	ddl	m
Z
ddl	mZddl	mZdd	l	m
Z
dd
l	mZddl	mZdd
lmZddlmZddlmZede
d�Zgd�ZGdd�de�ZGdd�de�ZGdd�de
e�ZGdd�dee�ZGdd�dee�ZGdd�dee�ZdS)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.

�)�annotationsN)�deque)�time)�Any)�	Awaitable)�Deque)�Generic)�Optional)�TypeVar�)�await_fallback)�
await_only)�memoized_property�_T)�bound)�Empty�Full�Queuec@�eZdZdZdS)rz4Exception raised by Queue.get(block=0)/get_nowait().N��__name__�
__module__�__qualname__�__doc__�rr�@/usr/local/lib/python3.10/dist-packages/sqlalchemy/util/queue.pyr,�rc@r)rz4Exception raised by Queue.put(block=0)/put_nowait().Nrrrrrr2rrc@sveZdZUded<ded<d d!dd�Zd"d
d�Zd"dd
�Zd#dd�Zd$dd�Z	d%d&dd�Z	d'dd�Z
d%d(dd�ZdS))�QueueCommon�int�maxsize�bool�use_liforFcC�dS�Nr��selfrr!rrr�__init__<szQueueCommon.__init__�returncC�t��r#��NotImplementedError�r%rrr�empty>�zQueueCommon.emptycCr(r#r)r+rrr�fullAr-zQueueCommon.fullcCr(r#r)r+rrr�qsizeDr-zQueueCommon.qsize�itemr�NonecCr(r#r)�r%r0rrr�
put_nowaitGr-zQueueCommon.put_nowaitTN�block�timeout�Optional[float]cCr(r#r))r%r0r4r5rrr�putJszQueueCommon.putcCr(r#r)r+rrr�
get_nowaitOr-zQueueCommon.get_nowaitcCr(r#r))r%r4r5rrr�getRr-zQueueCommon.get�rF�rrr!r �r'r �r'r�r0rr'r1�TN�r0rr4r r5r6r'r1�r'r�r4r r5r6r'r)rrr�__annotations__r&r,r.r/r3r7r8r9rrrrr8s




�
rc@s�eZdZUded<d.d/d	d
�Zd0dd
�Zd1dd�Zd1dd�Z	d2d3dd�Zd4dd�Z	d2d5dd�Z
d6d d!�Zd7d"d#�Zd0d$d%�Z
d1d&d'�Zd1d(d)�Zd4d*d+�Zd6d,d-�ZdS)8rz	Deque[_T]�queuerFrrr!r cCs:|�|�t��|_t�|j�|_t�|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)�_init�	threading�RLock�mutex�	Condition�	not_empty�not_fullr!r$rrrr&Ys



zQueue.__init__r'cC�2|j�|��Wd�S1swYdS)z9Return the approximate size of the queue (not reliable!).N)rH�_qsizer+rrrr/ps$�zQueue.qsizecCrL)zKReturn True if the queue is empty, False otherwise (not
        reliable!).N)rH�_emptyr+rrrr,v�$�zQueue.emptycCrL)zJReturn True if the queue is full, False otherwise (not
        reliable!).N)rH�_fullr+rrrr.}rOz
Queue.fullTNr0rr4r5r6r1cCs�|j�T|s
|��rt�n8|dur|��r|j��|��sn&|dkr'td��t�|}|��rE|t�}|dkr;t�|j�|�|��s0|�|�|j��Wd�dS1sZwYdS)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�)	rKrPr�wait�
ValueError�_time�_putrJ�notify)r%r0r4r5�endtime�	remainingrrrr7�s,�
��

�
"�z	Queue.putcCs|�|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)r7r2rrrr3�szQueue.put_nowaitcCs�|j�T|s
|��rt�n8|dur|��r|j��|��sn&|dkr'td��t�|}|��rE|t�}|dkr;t�|j�|�|��s0|��}|j��|Wd�S1sZwYdS)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).

        NrrQrR)	rJrNrrSrTrU�_getrKrW)r%r4r5rXrYr0rrrr9�s.�
��

�
$�z	Queue.getcCs
|�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)r9r+rrrr8�s
zQueue.get_nowaitcCs||_t�|_dSr#)rrrD)r%rrrrrE�szQueue._initcCs
t|j�Sr#)�lenrDr+rrrrM��
zQueue._qsizecCs|jSr#)rDr+rrrrN�szQueue._emptycCs|jdkot|j�|jkS)Nr)rr[rDr+rrrrP�szQueue._fullcCs|j�|�dSr#)rD�appendr2rrrrV�sz
Queue._putcCs|jr|j��S|j��Sr#)r!rD�pop�popleftr+rrrrZ�s

z
Queue._getr:r;r=r<r?r@r>rBrA)rrr'r1)rrrrCr&r/r,r.r7r3r9r8rErMrNrPrVrZrrrrrVs"



�
"
 
	



rc@s�eZdZejred'dd��Znee�Zd(d)d
d�Zd*dd�Z	dd�Z
dd�Zed+dd��Z
d,dd�Z	d-d.d!d"�Zd/d#d$�Zd-d0d%d&�ZdS)1�AsyncAdaptedQueue�	coroutine�Awaitable[Any]r'rcCr"r#r)rarrr�await_�szAsyncAdaptedQueue.await_rFrrr!r cCs||_||_dSr#)r!rr$rrrr&�s
zAsyncAdaptedQueue.__init__cC�
|j��Sr#)�_queuer,r+rrrr,�r\zAsyncAdaptedQueue.emptycCrdr#)rer.r+rrrr.r\zAsyncAdaptedQueue.fullcCrdr#)rer/r+rrrr/r\zAsyncAdaptedQueue.qsize�asyncio.Queue[_T]cCs*|jrtj|jd�}|Stj|jd�}|S)N)r)r!�asyncio�	LifoQueuerr)r%rDrrrres
�zAsyncAdaptedQueue._queuer0r1c
Cs6z	|j�|�WdStjy}zt�|�d}~wwr#)rer3rg�	QueueFullr)r%r0�errrrrr3s��zAsyncAdaptedQueue.put_nowaitTNr4r5r6c
Csx|s|�|�Sz |dur|�t�|j�|�|��WdS|�|j�|��WdStjtjfy;}zt�|�d}~wwr#)	r3rcrg�wait_forrer7ri�TimeoutErrorr)r%r0r4r5rjrrrr7s
 ��zAsyncAdaptedQueue.putc
Cs0z|j��WStjy}zt�|�d}~wwr#)rer8rg�
QueueEmptyr)r%rjrrrr8+s��zAsyncAdaptedQueue.get_nowaitc
Csj|s|��Sz|dur|�t�|j��|��WS|�|j���WStjtjfy4}zt�|�d}~wwr#)	r8rcrgrkrer9rmrlr)r%r4r5rjrrrr91s���zAsyncAdaptedQueue.get)rarbr'rr:r;r<)r'rfr>r?r@rArB)rrr�typing�
TYPE_CHECKING�staticmethodrcr
r&r,r.r/rrer3r7r8r9rrrrr`�s 

�
r`c@seZdZejs
ee�ZdSdS)�FallbackAsyncAdaptedQueueN)rrrrnrorprrcrrrrrq@s�rq)r�
__future__rrg�collectionsrrFrrUrnrrrrr	r
�concurrencyrr
�langhelpersrr�__all__�	Exceptionrrrrr`rqrrrr�<module>s2P