s d Z ddlmZ ddlmZ ddlmZ g dZ 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)EmptyFullQueuec e Zd ZdZdS )r z4Exception raised by Queue.get(block=0)/get_nowait().N__name__ __module____qualname____doc__ i/builddir/build/BUILD/cloudlinux-venv-1.0.10/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 ZddZd Zd Zd Zdd Zd ZddZ d Z d Zd Zd Z d Zd Zd ZdS )r r Fc | | t j | _ t j | j | _ t j | j | _ || _ dS )zInitialize 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 RLockmutex Condition not_emptynot_fulluse_lifo)selfmaxsizer s r __init__zQueue.__init__+ s^ 7 _&& #,TZ88 "+DJ77 r c | j | }| j |S )z9Return the approximate size of the queue (not reliable!).)r acquire_qsizereleaser ns r qsizezQueue.qsizeB s> KKMM r c | j | }| j |S )zKReturn True if the queue is empty, False otherwise (not reliable!).)r r" _emptyr$ r% s r emptyzQueue.emptyJ s> KKMM r c | j | }| j |S )zJReturn True if the queue is full, False otherwise (not reliable!).)r r" _fullr$ r% s r fullz Queue.fullS s> JJLL r TNc | j |s| rt n|B| r-| j | -n|dk rt d t |z }| rL|t z }|dk rt | j | | L| | | j | j dS # | j w xY w)a Put 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 )r r" r, r wait ValueError_time_putr notifyr$ )r itemblocktimeoutendtime remainings r putz Queue.put\ sR $ 2::<<