+
    G8
k¦2  ã                  ó:  € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	H
t
Ht ^ RIHt ^ RIHtHt ^ RIHt ]! R4      t. ROt ! R R]4      t ! R R]4      tR R lt ! R R]
],          4      t ! R R	]
],          4      t ! R R
]4      t ! R R]4      tR# )aÆ  Asynchronous queues for coroutines. These classes are very similar
to those provided in the standard library's `asyncio package
<https://docs.python.org/3/library/asyncio-queue.html>`_.

.. warning::

   Unlike the standard library's `queue` module, the classes defined here
   are *not* thread-safe. To use these queues from another thread,
   use `.IOLoop.add_callback` to transfer control to the `.IOLoop` thread
   before calling any queue methods.

)ÚannotationsN)Ú	Awaitable)ÚAnyÚGenericÚTypeVar)Úioloop)ÚFutureÚ"future_set_result_unless_cancelled)ÚEventÚ_TÚQueueÚPriorityQueueÚ	LifoQueueÚ	QueueFullÚ
QueueEmptyc                  ó   € ] tR t^-tRtRtR# )r   z:Raised by `.Queue.get_nowait` when the queue has no items.© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r   ó    Ú…/opt/data/installs/351f81cc06284494/environments/aa258815729c481f8402f54f4c368f83/venv/lib/python3.14/site-packages/tornado/queues.pyr   r   -   s   † ÙDãr   c                  ó   € ] tR t^3tRtRtR# )r   zBRaised by `.Queue.put_nowait` when a queue is at its maximum size.r   Nr   r   r   r   r   r   3   s   † ÙLãr   c               ó$   € V ^8„  d   QhRRRRRR/# )é   Úfuturer   Útimeoutz!None | float | datetime.timedeltaÚreturnÚNoner   )Úformats   "r   Ú__annotate__r$   9   s(   € ÷ 	Sñ 	S˜ð 	SÐ*Kð 	SÐPTñ 	Sr   c                ó´   a aa€ VeQ   R V 3R llp\         P                  P                  4       oSP                  W4      oS P	                  VV3R l4       R # R # )Nc               ó   € V ^8„  d   QhRR/# ©r   r!   r"   r   )r#   s   "r   r$   Ú"_set_timeout.<locals>.__annotate__<   s   € ÷ 	5ñ 	5˜Dñ 	5r   c                 ój   <€ S P                  4       '       g   S P                  \        4       4       R # R # ©N)ÚdoneÚset_exceptionÚTimeoutError)r   s   €r   Ú
on_timeoutÚ _set_timeout.<locals>.on_timeout<   s#   ø€ Ø—;‘;—=’=Ø×$Ñ$¤\£^Ö4ñ !r   c                ó&   <€ SP                  S4      # r*   )Úremove_timeout)Ú_Úio_loopÚtimeout_handles   &€€r   Ú<lambda>Ú_set_timeout.<locals>.<lambda>B   s   ø€ ¨7×+AÑ+AÀ.Ô+Qr   )r   ÚIOLoopÚcurrentÚadd_timeoutÚadd_done_callback)r   r    r.   r3   r4   s   f& @@r   Ú_set_timeoutr;   9   sK   ú€ ØÒ÷	5ð 	5ô —-‘-×'Ñ'Ó)ˆØ ×,Ñ,¨WÓAˆØ× Ñ Õ!QÖRñ r   c                  ó.   € ] tR t^EtR R ltR R ltRtR# )Ú_QueueIteratorc               ó    € V ^8„  d   QhRRRR/# )r   Úqz	Queue[_T]r!   r"   r   )r#   s   "r   r$   Ú_QueueIterator.__annotate__F   s   € ÷ ñ ˜)ð ¨ñ r   c                	ó   € Wn         R # r*   ©r?   )Úselfr?   s   &&r   Ú__init__Ú_QueueIterator.__init__F   s   € ØŽr   c               ó   € V ^8„  d   QhRR/# )r   r!   úAwaitable[_T]r   )r#   s   "r   r$   r@   I   s   € ÷ ñ ˜=ñ r   c                	ó6   € V P                   P                  4       # r*   )r?   Úget©rC   s   &r   Ú	__anext__Ú_QueueIterator.__anext__I   s   € Ø�v‰v�z‰z‹|Ðr   rB   N)r   r   r   r   rD   rK   r   r   r   r   r=   r=   E   s   † õ÷ñ r   r=   c                  ó4  € ] tR t^Mt$ RtRtR]R&   R.R R llt]R R l4       t	R	 R
 lt
R R ltR R ltR/R R lltR R ltR/R R lltR R ltR R ltR/R R lltR R ltR R ltR R  ltR! R" ltR# R$ ltR% R& ltR' R( ltR) R* ltR+ R, ltR-tR# )0r   aÝ  Coordinate producer and consumer coroutines.

If maxsize is 0 (the default) the queue size is unbounded.

.. testcode::

    import asyncio
    from tornado.ioloop import IOLoop
    from tornado.queues import Queue

    q = Queue(maxsize=2)

    async def consumer():
        async for item in q:
            try:
                print('Doing work on %s' % item)
                await asyncio.sleep(0.01)
            finally:
                q.task_done()

    async def producer():
        for item in range(5):
            await q.put(item)
            print('Put %s' % item)

    async def main():
        # Start consumer without waiting (since it never finishes).
        IOLoop.current().spawn_callback(consumer)
        await producer()     # Wait for producer to put all tasks.
        await q.join()       # Wait for consumer to finish all tasks.
        print('Done')

    asyncio.run(main())

.. testoutput::

    Put 0
    Put 1
    Doing work on 0
    Put 2
    Doing work on 1
    Put 3
    Doing work on 2
    Put 4
    Doing work on 3
    Doing work on 4
    Done


In versions of Python without native coroutines (before 3.5),
``consumer()`` could be written as::

    @gen.coroutine
    def consumer():
        while True:
            item = yield q.get()
            try:
                print('Doing work on %s' % item)
                yield gen.sleep(0.01)
            finally:
                q.task_done()

.. versionchanged:: 4.3
   Added ``async for`` support in Python 3.5.

Nr   Ú_queuec               ó    € V ^8„  d   QhRRRR/# )r   ÚmaxsizeÚintr!   r"   r   )r#   s   "r   r$   ÚQueue.__annotate__•   s   € ÷ ñ  ð ¨Dñ r   c                	ó@  € Vf   \        R4      hV^ 8  d   \        R4      hWn        V P                  4        \        P
                  ! . 4      V n        \        P
                  ! . 4      V n        ^ V n        \        4       V n
        V P                  P                  4        R # )Nzmaxsize can't be Nonezmaxsize can't be negative)Ú	TypeErrorÚ
ValueErrorÚ_maxsizeÚ_initÚcollectionsÚdequeÚ_gettersÚ_puttersÚ_unfinished_tasksr
   Ú	_finishedÚset)rC   rP   s   &&r   rD   ÚQueue.__init__•   s   € ØŠ?ÜÐ3Ó4Ð4à�QŒ;ÜÐ8Ó9Ð9àŒØ�
‰
ŒÜ7B×7HÒ7HÈÓ7LˆŒÜDO×DUÒDUØóE
ˆŒð "#ˆÔÜ›ˆŒØ�‰×ÑÖr   c               ó   € V ^8„  d   QhRR/# ©r   r!   rQ   r   )r#   s   "r   r$   rR   §   s   € ÷ ñ ˜ñ r   c                ó   € V P                   # )z%Number of items allowed in the queue.)rV   rJ   s   &r   rP   ÚQueue.maxsize¦   s   € ð �}‰}Ðr   c               ó   € V ^8„  d   QhRR/# ra   r   )r#   s   "r   r$   rR   «   s   € ÷  ñ  �sñ  r   c                ó,   € \        V P                  4      # )zNumber of items in the queue.)ÚlenrN   rJ   s   &r   ÚqsizeÚQueue.qsize«   s   € ä�4—;‘;ÓÐr   c               ó   € V ^8„  d   QhRR/# ©r   r!   Úboolr   )r#   s   "r   r$   rR   ¯   s   € ÷ ñ �tñ r   c                	ó$   € V P                   '       * # r*   ©rN   rJ   s   &r   ÚemptyÚQueue.empty¯   s   € Ø—;‘;ŒÐr   c               ó   € V ^8„  d   QhRR/# rj   r   )r#   s   "r   r$   rR   ²   s   € ÷ 0ñ 0�dñ 0r   c                	ób   € V P                   ^ 8X  d   R# V P                  4       V P                   8¬  # )é    F)rP   rg   rJ   s   &r   ÚfullÚ
Queue.full²   s&   € Ø�<‰<˜1ÔÙà—:‘:“< 4§<¡<Ñ/Ð/r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úitemr   r    ú!float | datetime.timedelta | Noner!   zFuture[None]r   )r#   s   "r   r$   rR   ¸   s$   € ÷ ñ ØðØ!Bðà	ñr   c                óÒ   € \        4       p V P                  V4       VP                  R4       V#   \         d,    T P                  P                  Y34       \        Y24        T# i ; i)aò  Put an item into the queue, perhaps waiting until there is room.

Returns a Future, which raises `TimeoutError` after a
timeout.

``timeout`` may be a number denoting a time (on the same
scale as `tornado.ioloop.IOLoop.time`, normally `time.time`), or a
`datetime.timedelta` object for a deadline relative to the
current time.

.. versionchanged:: 6.6
   A ``timeout`` argument of zero will either return or raise immediately.
   Previously, zero was treated equivalent to ``None`` (wait forever).
N)r   Ú
put_nowaitÚ
set_resultr   r[   Úappendr;   )rC   rv   r    r   s   &&& r   ÚputÚ	Queue.put¸   se   € ô"  &›xˆð	$Ø�O‰O˜DÔ!ð
 ×Ñ˜dÔ#Øˆøô ô 	*Ø�M‰M× Ñ  $ Ô0Ü˜Õ)ð ˆð	*ús   Œ0 °2A&Á%A&c               ó    € V ^8„  d   QhRRRR/# ©r   rv   r   r!   r"   r   )r#   s   "r   r$   rR   Ó   s   € ÷ &ñ &˜rð & dñ &r   c                ój  € V P                  4        V P                  '       dd   V P                  4       '       g   Q R4       hV P                  P                  4       pV P	                  V4       \        W P                  4       4       R# V P                  4       '       d   \        hV P	                  V4       R# )zkPut an item into the queue without blocking.

If no free slot is immediately available, raise `QueueFull`.
z)queue non-empty, why are getters waiting?N)	Ú_consume_expiredrZ   rn   ÚpopleftÚ_Queue__put_internalr	   Ú_getrs   r   )rC   rv   Úgetters   && r   ry   ÚQueue.put_nowaitÓ   s{   € ð
 	×ÑÔØ�=�=ˆ=Ø—:‘:—<’<ÐLÐ!LÓL�<Ø—]‘]×*Ñ*Ó,ˆFØ×Ñ Ô%Ü.¨v·y±y³{ÖCØ�Y‰Y�[Š[ÜˆOà×Ñ Ö%r   c               ó    € V ^8„  d   QhRRRR/# )r   r    rw   r!   rG   r   )r#   s   "r   r$   rR   ã   s   € ÷ ñ Ð<ð Èñ r   c                óÊ   € \        4       p VP                  V P                  4       4       V#   \         d+    T P                  P                  T4       \        Y!4        T# i ; i)a[  Remove and return an item from the queue.

Returns an awaitable which resolves once an item is available, or raises
`TimeoutError` after a timeout.

``timeout`` may be a number denoting a time (on the same
scale as `tornado.ioloop.IOLoop.time`, normally `time.time`), or a
`datetime.timedelta` object for a deadline relative to the
current time.

.. note::

   The ``timeout`` argument of this method differs from that
   of the standard library's `queue.Queue.get`. That method
   interprets numeric values as relative timeouts; this one
   interprets them as absolute deadlines and requires
   ``timedelta`` objects for relative timeouts (consistent
   with other timeouts in Tornado).

.. versionchanged:: 6.6
   A ``timeout`` argument of zero will either return or raise immediately.
   Previously, zero was treated equivalent to ``None`` (wait forever).
)r   rz   Ú
get_nowaitr   rZ   r{   r;   )rC   r    r   s   && r   rI   Ú	Queue.getã   s\   € ô0 $›Xˆð	*Ø×Ñ˜dŸo™oÓ/Ô0ð ˆøô ô 	*Ø�M‰M× Ñ  Ô(Ü˜Õ)Øˆð	*ús   Œ- ­1A"Á!A"c               ó   € V ^8„  d   QhRR/# ©r   r!   r   r   )r#   s   "r   r$   rR     s   € ÷ ñ ˜Bñ r   c                ój  € V P                  4        V P                  '       dg   V P                  4       '       g   Q R4       hV P                  P                  4       w  rV P	                  V4       \        VR4       V P                  4       # V P                  4       '       d   V P                  4       # \        h)z…Remove and return an item from the queue without blocking.

Return an item if one is immediately available, else raise
`QueueEmpty`.
z(queue not full, why are putters waiting?N)	r�   r[   rs   r‚   rƒ   r	   r„   rg   r   )rC   rv   Úputters   &  r   r‰   ÚQueue.get_nowait  s„   € ð 	×ÑÔØ�=�=ˆ=Ø—9‘9—;’;ÐJÐ JÓJ�;ØŸ=™=×0Ñ0Ó2‰LˆDØ×Ñ Ô%Ü.¨v°tÔ<Ø—9‘9“;ÐØ�Z‰Z�\Š\Ø—9‘9“;ÐäÐr   c               ó   € V ^8„  d   QhRR/# r'   r   )r#   s   "r   r$   rR     s   € ÷ !ñ !˜4ñ !r   c                óÊ   € V P                   ^ 8:  d   \        R4      hV ;P                   ^,          un         V P                   ^ 8X  d   V P                  P                  4        R# R# )a�  Indicate that a formerly enqueued task is complete.

Used by queue consumers. For each `.get` used to fetch a task, a
subsequent call to `.task_done` tells the queue that the processing
on the task is complete.

If a `.join` is blocking, it resumes when all items have been
processed; that is, when every `.put` is matched by a `.task_done`.

Raises `ValueError` if called more times than `.put`.
z!task_done() called too many timesN)r\   rU   r]   r^   rJ   s   &r   Ú	task_doneÚQueue.task_done  sR   € ð ×!Ñ! QÔ&ÜÐ@ÓAÐAØ×Ò !Õ#ÕØ×!Ñ! QÔ&Ø�N‰N×ÑÖ ñ 'r   c               ó    € V ^8„  d   QhRRRR/# )r   r    rw   r!   zAwaitable[None]r   )r#   s   "r   r$   rR   '  s   € ÷ ,ñ ,Ø8ð,à	ñ,r   c                ó8   € V P                   P                  V4      # )a!  Block until all items in the queue are processed.

Returns an awaitable, which raises `TimeoutError` after a
timeout.

.. versionchanged:: 6.6
   A ``timeout`` argument of zero will either return or raise immediately.
   Previously, zero was treated equivalent to ``None`` (wait forever).
)r]   Úwait)rC   r    s   &&r   ÚjoinÚ
Queue.join'  s   € ð �~‰~×"Ñ" 7Ó+Ð+r   c               ó   € V ^8„  d   QhRR/# )r   r!   z_QueueIterator[_T]r   )r#   s   "r   r$   rR   5  s   € ÷ $ñ $Ð-ñ $r   c                	ó   € \        V 4      # r*   )r=   rJ   s   &r   Ú	__aiter__ÚQueue.__aiter__5  s   € Ü˜dÓ#Ð#r   c               ó   € V ^8„  d   QhRR/# r'   r   )r#   s   "r   r$   rR   9  s   € ÷ *ñ *�tñ *r   c                	ó:   € \         P                  ! 4       V n        R # r*   )rX   rY   rN   rJ   s   &r   rW   ÚQueue._init9  s   € Ü!×'Ò'Ó)ˆŽr   c               ó   € V ^8„  d   QhRR/# rŒ   r   )r#   s   "r   r$   rR   <  s   € ÷ %ñ %�bñ %r   c                	ó6   € V P                   P                  4       # r*   )rN   r‚   rJ   s   &r   r„   Ú
Queue._get<  s   € Ø�{‰{×"Ñ"Ó$Ð$r   c               ó    € V ^8„  d   QhRRRR/# r   r   )r#   s   "r   r$   rR   ?  ó   € ÷ !ñ !˜ð ! ñ !r   c                	ó<   € V P                   P                  V4       R # r*   ©rN   r{   ©rC   rv   s   &&r   Ú_putÚ
Queue._put?  ó   € Ø�‰×Ñ˜4Ö r   c               ó    € V ^8„  d   QhRRRR/# r   r   )r#   s   "r   r$   rR   D  s   € ÷ ñ  2ð ¨$ñ r   c                	óŽ   € V ;P                   ^,          un         V P                  P                  4        V P                  V4       R# )é   N)r\   r]   Úclearr¨   r§   s   &&r   Ú__put_internalÚQueue.__put_internalD  s.   € Ø×Ò !Õ#ÕØ�‰×ÑÔØ�	‰	�$Žr   c               ó   € V ^8„  d   QhRR/# r'   r   )r#   s   "r   r$   rR   I  s   € ÷ $ñ $ $ñ $r   c                	ól  € V P                   '       dK   V P                   ^ ,          ^,          P                  4       '       d   V P                   P                  4        K\  V P                  '       dF   V P                  ^ ,          P                  4       '       d   V P                  P                  4        KU  R# R# )rr   N)r[   r+   r‚   rZ   rJ   s   &r   r�   ÚQueue._consume_expiredI  sn   € à�m�mˆm §¡¨aÕ 0°Õ 3× 8Ñ 8× :Ò :Ø�M‰M×!Ñ!Ö#à�m�mˆm §¡¨aÕ 0× 5Ñ 5× 7Ò 7Ø�M‰M×!Ñ!Ö#ñ !8‰mr   c               ó   € V ^8„  d   QhRR/# ©r   r!   Ústrr   )r#   s   "r   r$   rR   Q  s   € ÷ Nñ N˜#ñ Nr   c                	ó€   € R \        V 4      P                   R\        \        V 4      4       RV P	                  4        R2# )Ú<z at Ú Ú>)Útyper   ÚhexÚidÚ_formatrJ   s   &r   Ú__repr__ÚQueue.__repr__Q  s7   € Ø”4˜“:×&Ñ&Ð' t¬C´°4³«M¨?¸!¸D¿L¹L»NÐ;KÈ1ÐMÐMr   c               ó   € V ^8„  d   QhRR/# rµ   r   )r#   s   "r   r$   rR   T  s   € ÷ ;ñ ;˜ñ ;r   c                	óV   € R \        V 4      P                   RV P                  4        R2# )r¸   r¹   rº   )r»   r   r¾   rJ   s   &r   Ú__str__ÚQueue.__str__T  s)   € Ø”4˜“:×&Ñ&Ð' q¨¯©«Ð(8¸Ð:Ð:r   c               ó   € V ^8„  d   QhRR/# rµ   r   )r#   s   "r   r$   rR   W  s   € ÷ 
ñ 
˜ñ 
r   c                	ó¬  € R V P                   : 2p\        V RR4      '       d   VRV P                  ,          ,          pV P                  '       d$   VR\	        V P                  4      ,          ,          pV P
                  '       d$   VR\	        V P
                  4      ,          ,          pV P                  '       d   VRV P                  ,          ,          pV# )zmaxsize=rN   Nz	 queue=%rz getters[%s]z putters[%s]z	 tasks=%s)rP   ÚgetattrrN   rZ   rf   r[   r\   )rC   Úresults   & r   r¾   ÚQueue._formatW  s�   € Ø˜DŸL™LÑ+Ð,ˆÜ�4˜ 4×(Ò(Ø�k D§K¡KÕ/Õ/ˆFØ�=�=ˆ=Ø�n¤s¨4¯=©=Ó'9Õ9Õ9ˆFØ�=�=ˆ=Ø�n¤s¨4¯=©=Ó'9Õ9Õ9ˆFØ×!×!Ð!Ø�k D×$:Ñ$:Õ:Õ:ˆFØˆr   )r]   rZ   rV   r[   rN   r\   )rr   r*   )r   r   r   r   r   rN   Ú__annotations__rD   ÚpropertyrP   rg   rn   rs   r|   ry   rI   r‰   r’   r—   r›   rW   r„   r¨   rƒ   r�   r¿   rÃ   r¾   r   r   r   r   r   r   M   s�   ‡ ñAðJ €FˆCÓ÷ð" ôó ðõ õõ0÷õ6&÷ õ@õ$!÷$,õ$õ*õ%õ!õ
õ
$õNõ;÷
ñ 
r   c                  ó>   € ] tR tRtRtR R ltR R ltR R ltR	tR
# )r   id  ab  A `.Queue` that retrieves entries in priority order, lowest first.

Entries are typically tuples like ``(priority number, data)``.

.. testcode::

    import asyncio
    from tornado.queues import PriorityQueue

    async def main():
        q = PriorityQueue()
        q.put((1, 'medium-priority item'))
        q.put((0, 'high-priority item'))
        q.put((10, 'low-priority item'))

        print(await q.get())
        print(await q.get())
        print(await q.get())

    asyncio.run(main())

.. testoutput::

    (0, 'high-priority item')
    (1, 'medium-priority item')
    (10, 'low-priority item')
c               ó   € V ^8„  d   QhRR/# r'   r   )r#   s   "r   r$   ÚPriorityQueue.__annotate__�  ó   € ÷ ñ �tñ r   c                	ó   € . V n         R # r*   rm   rJ   s   &r   rW   ÚPriorityQueue._init�  ó	   € ØˆŽr   c               ó    € V ^8„  d   QhRRRR/# r   r   )r#   s   "r   r$   rÎ   „  s   € ÷ *ñ *˜ð * ñ *r   c                	óH   € \         P                  ! V P                  V4       R # r*   )ÚheapqÚheappushrN   r§   s   &&r   r¨   ÚPriorityQueue._put„  s   € Ü�Š�t—{‘{ DÖ)r   c               ó   € V ^8„  d   QhRR/# rŒ   r   )r#   s   "r   r$   rÎ   ‡  s   € ÷ *ñ *�bñ *r   c                	óB   € \         P                  ! V P                  4      # r*   )rÕ   ÚheappoprN   rJ   s   &r   r„   ÚPriorityQueue._get‡  s   € Ü�}Š}˜TŸ[™[Ó)Ð)r   rm   N©	r   r   r   r   r   rW   r¨   r„   r   r   r   r   r   r   d  s   † ñõ8õ*÷*ñ *r   c                  ó>   € ] tR tRtRtR R ltR R ltR R ltR	tR
# )r   i‹  a€  A `.Queue` that retrieves the most recently put items first.

.. testcode::

    import asyncio
    from tornado.queues import LifoQueue

    async def main():
        q = LifoQueue()
        q.put(3)
        q.put(2)
        q.put(1)

        print(await q.get())
        print(await q.get())
        print(await q.get())

    asyncio.run(main())

.. testoutput::

    1
    2
    3
c               ó   € V ^8„  d   QhRR/# r'   r   )r#   s   "r   r$   ÚLifoQueue.__annotate__¦  rÏ   r   c                	ó   € . V n         R # r*   rm   rJ   s   &r   rW   ÚLifoQueue._init¦  rÒ   r   c               ó    € V ^8„  d   QhRRRR/# r   r   )r#   s   "r   r$   rß   ©  r¤   r   c                	ó<   € V P                   P                  V4       R # r*   r¦   r§   s   &&r   r¨   ÚLifoQueue._put©  rª   r   c               ó   € V ^8„  d   QhRR/# rŒ   r   )r#   s   "r   r$   rß   ¬  s   € ÷ !ñ !�bñ !r   c                	ó6   € V P                   P                  4       # r*   )rN   ÚpoprJ   s   &r   r„   ÚLifoQueue._get¬  s   € Ø�{‰{�‰Ó Ð r   rm   NrÜ   r   r   r   r   r   ‹  s   † ñõ4õ!÷!ñ !r   )r   r   r   r   r   )r   Ú
__future__r   rX   ÚdatetimerÕ   Úcollections.abcr   Útypingr   r   r   Útornador   Útornado.concurrentr   r	   Útornado.locksr
   r   Ú__all__Ú	Exceptionr   r   r;   r=   r   r   r   r   r   r   Ú<module>rò      s’   ðñõ #ã Û Û Ý %ß (Ñ (å ß IÝ áˆTƒ]€â
L€ô	�ô 	ô	�	ô 	õ	Sô�W˜R•[ô ôTˆG�B�Kô Tôn$*�Eô $*ôN"!�ö "!r   