+
    ‚V@ilC  ã                   ó0  € ^ RI t ^ RIt^ RIt^ RIHtHt ^ RIHtHt ^ RI	H
t
HtHtHtHt ^ RI	t	]	P                  '       d	   ^ RI	HtHt . ROt ! R R4      t ! R R]4      t ! R R4      t ! R R4      t ! R R]4      t ! R R	]4      t ! R R
4      tR# )é    N)ÚgenÚioloop)ÚFutureÚ"future_set_result_unless_cancelled)ÚUnionÚOptionalÚTypeÚAnyÚ	Awaitable)ÚDequeÚSetÚ	ConditionÚEventÚ	SemaphoreÚBoundedSemaphoreÚLockc                   óH   a € ] tR t^t o RtV 3R lR ltV 3R lR ltRtV tR# )Ú_TimeoutGarbageCollectorzÍBase class for objects that periodically clean up timed-out waiters.

Avoids memory leak in a common pattern like:

    while True:
        yield condition.wait(short_timeout)
        print('looping....')
c                ó   <€ V ^8„  d   QhRR/# ©é   ÚreturnN© )ÚformatÚ__classdict__s   "€Ú//usr/lib/python3/dist-packages/tornado/locks.pyÚ__annotate__Ú%_TimeoutGarbageCollector.__annotate__)   s   ø€ ÷ ñ ˜$ñ ó    c                óH   € \         P                  ! 4       V n        ^ V n        R# )r   N)ÚcollectionsÚdequeÚ_waitersÚ	_timeouts©Úselfs   &r   Ú__init__Ú!_TimeoutGarbageCollector.__init__)   s   € Ü#×)Ò)Ó+ˆŒØˆŽr   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r   -   s   ø€ ÷ Xñ X $ñ Xr   c                óÄ   € V ;P                   ^,          un         V P                   ^d8”  d6   ^ V n         \        P                  ! R V P                   4       4      V n        R# R# )é   c              3   óT   "  € T F  qP                  4       '       d   K  Vx € K   	  R # 5i©N)Údone)Ú.0Úws   & r   Ú	<genexpr>Ú<_TimeoutGarbageCollector._garbage_collect.<locals>.<genexpr>2   s   é € Ð-W¹°AÏfÉfÏh¯aªa»ùs   ‚(ž
(N)r$   r!   r"   r#   r%   s   &r   Ú_garbage_collectÚ)_TimeoutGarbageCollector._garbage_collect-   sD   € à�Š˜!Õ�Ø�>‰>˜CÔØˆDŒNÜ'×-Ò-Ñ-W¸¿ºÓ-WÓWˆDŽMñ  r   )r$   r#   N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r'   r3   Ú__static_attributes__Ú__classdictcell__©r   s   @r   r   r      s    ø‡ € ñ÷ð ÷Xö Xr   r   c                   ót   a € ] tR t^5t o RtV 3R lR ltRV 3R lR lltRV 3R lR lltV 3R	 lR
 ltRt	V t
R# )r   a  A condition allows one or more coroutines to wait until notified.

Like a standard `threading.Condition`, but does not need an underlying lock
that is acquired and released.

With a `Condition`, coroutines can wait to be notified by other coroutines:

.. testcode::

    import asyncio
    from tornado import gen
    from tornado.locks import Condition

    condition = Condition()

    async def waiter():
        print("I'll wait right here")
        await condition.wait()
        print("I'm done waiting")

    async def notifier():
        print("About to notify")
        condition.notify()
        print("Done notifying")

    async def runner():
        # Wait for waiter() and notifier() in parallel
        await gen.multi([waiter(), notifier()])

    asyncio.run(runner())

.. testoutput::

    I'll wait right here
    About to notify
    Done notifying
    I'm done waiting

`wait` takes an optional ``timeout`` argument, which is either an absolute
timestamp::

    io_loop = IOLoop.current()

    # Wait up to 1 second for a notification.
    await condition.wait(timeout=io_loop.time() + 1)

...or a `datetime.timedelta` for a timeout relative to the current time::

    # Wait up to 1 second.
    await condition.wait(timeout=datetime.timedelta(seconds=1))

The method returns False if there's no notification before the deadline.

.. versionchanged:: 5.0
   Previously, waiters could be notified synchronously from within
   `notify`. Now, the notification will always be received on the
   next iteration of the `.IOLoop`.
c                ó    <€ V ^8„  d   QhRS[ /# ©r   r   ©Ústr)r   r   s   "€r   r   ÚCondition.__annotate__q   s   ø€ ÷ ñ ™#ñ r   c                ó°   € R V P                   P                   2pV P                  '       d$   VR\        V P                  4      ,          ,          pVR,           # )Ú<z waiters[%s]Ú>)Ú	__class__r5   r#   Úlen)r&   Úresults   & r   Ú__repr__ÚCondition.__repr__q   sD   € Ø�T—^‘^×,Ñ,Ð-Ð.ˆØ�=�=ˆ=Ø�n¤s¨4¯=©=Ó'9Õ9Õ9ˆFØ˜�|Ðr   Nc                óp   <€ V ^8„  d   QhRS[ S[S[S[P                  3,          ,          RS[S[,          /# ©r   Útimeoutr   )r   r   ÚfloatÚdatetimeÚ	timedeltar   Úbool)r   r   s   "€r   r   rB   w   s6   ø€ ÷ ñ Ù¡¡e©X×-?Ñ-?Ð&?Õ @ÕAðá	‘4�ñr   c                ó  a aaa€ \        4       oS P                  P                  S4       V'       dP   R V V3R llp\        P                  P                  4       oSP                  W4      oSP                  VV3R l4       S# )z|Wait for `.notify`.

Returns a `.Future` that resolves ``True`` if the condition is notified,
or ``False`` after a timeout.
c                ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   Ú$Condition.wait.<locals>.__annotate__ƒ   s   € ÷ (ñ ( ñ (r   c                  ól   <€ SP                  4       '       g   \        SR 4       S P                  4        R# ©FN)r.   r   r3   ©r&   Úwaiters   €€r   Ú
on_timeoutÚ"Condition.wait.<locals>.on_timeoutƒ   s$   ø€ Ø—{‘{—}’}Ü6°v¸uÔEØ×%Ñ%Ö'r   c                 ó&   <€ SP                  S4      # r-   ©Úremove_timeout©Ú_Úio_loopÚtimeout_handles   &€€r   Ú<lambda>Ú Condition.wait.<locals>.<lambda>Š   s   ø€ ¨w×/EÑ/EÀnÔ/Ur   )r   r#   Úappendr   ÚIOLoopÚcurrentÚadd_timeoutÚadd_done_callback©r&   rM   rY   r`   ra   rX   s   f& @@@r   ÚwaitÚCondition.waitw   sc   û€ ô “ˆØ�‰×Ñ˜VÔ$ß÷(ñ (ô
 —m‘m×+Ñ+Ó-ˆGØ$×0Ñ0°ÓEˆNØ×$Ñ$Õ%UÔVØˆr   c                ó$   <€ V ^8„  d   QhRS[ RR/# )r   Únr   N©Úint)r   r   s   "€r   r   rB   �   s   ø€ ÷ 
=ñ 
=™ð 
= Dñ 
=r   c                ó  € . pV'       da   V P                   '       dO   V P                   P                  4       pVP                  4       '       d   KL  V^,          pVP                  V4       Kh  V F  p\	        VR4       K  	  R# )zWake ``n`` waiters.TN)r#   Úpopleftr.   rd   r   )r&   rm   ÚwaitersrX   s   &&  r   ÚnotifyÚCondition.notify�   sX   € àˆß�D—M—M�MØ—]‘]×*Ñ*Ó,ˆFØ—;‘;—=”=Ø�Q•�Ø—‘˜vÖ&ãˆFÜ.¨v°tÖ<ó r   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   rB   ™   s   ø€ ÷ (ñ (˜Dñ (r   c                óN   € V P                  \        V P                  4      4       R# )zWake all waiters.N)rs   rG   r#   r%   s   &r   Ú
notify_allÚCondition.notify_all™   s   € à�‰”C˜Ÿ™Ó&Ö'r   r   r-   ©r+   )r5   r6   r7   r8   r9   rI   rj   rs   rw   r:   r;   r<   s   @r   r   r   5   s3   ø‡ € ñ9÷vð ÷ò ÷,
=ò 
=÷(ö (r   c                   ó”   a € ] tR t^žt o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR	 ltV 3R
 lR lt	RV 3R lR llt
RtV tR# )r   a6  An event blocks coroutines until its internal flag is set to True.

Similar to `threading.Event`.

A coroutine can wait for an event to be set. Once it is set, calls to
``yield event.wait()`` will not block unless the event has been cleared:

.. testcode::

    import asyncio
    from tornado import gen
    from tornado.locks import Event

    event = Event()

    async def waiter():
        print("Waiting for event")
        await event.wait()
        print("Not waiting this time")
        await event.wait()
        print("Done")

    async def setter():
        print("About to set the event")
        event.set()

    async def runner():
        await gen.multi([waiter(), setter()])

    asyncio.run(runner())

.. testoutput::

    Waiting for event
    About to set the event
    Not waiting this time
    Done
c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   ÚEvent.__annotate__Æ   s   ø€ ÷ ñ ˜$ñ r   c                ó2   € R V n         \        4       V n        R# rV   )Ú_valueÚsetr#   r%   s   &r   r'   ÚEvent.__init__Æ   s   € ØˆŒÜ›ˆŽr   c                ó    <€ V ^8„  d   QhRS[ /# r?   r@   )r   r   s   "€r   r   r|   Ê   s   ø€ ÷ 
ñ 
™#ñ 
r   c                ó†   € R P                  V P                  P                  V P                  4       '       d   R4      # R4      # )z<{} {}>r   Úclear)r   rF   r5   Úis_setr%   s   &r   rI   ÚEvent.__repr__Ê   s<   € Ø×ÑØ�N‰N×#Ñ#Ø—[‘[—]’]ˆEó
ð 	
à(/ó
ð 	
r   c                ó    <€ V ^8„  d   QhRS[ /# r?   )rQ   )r   r   s   "€r   r   r|   Ð   s   ø€ ÷ ñ ™ñ r   c                ó   € V P                   # )z-Return ``True`` if the internal flag is true.©r~   r%   s   &r   r„   ÚEvent.is_setÐ   s   € à�{‰{Ðr   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r|   Ô   s   ø€ ÷ 
)ñ 
)�Tñ 
)r   c                ó´   € V P                   '       gF   RV n         V P                   F,  pVP                  4       '       d   K  VP                  R4       K.  	  R# R# )zsSet the internal flag to ``True``. All waiters are awakened.

Calling `.wait` once the flag is set will not block.
TN)r~   r#   r.   Ú
set_result)r&   Úfuts   & r   r   Ú	Event.setÔ   s>   € ð
 �{�{ˆ{ØˆDŒKà—}”}�Ø—x‘x—z”zØ—N‘N 4Ö(ó %ñ r   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r|   à   s   ø€ ÷ ñ �tñ r   c                ó   € RV n         R# )z[Reset the internal flag to ``False``.

Calls to `.wait` will block until `.set` is called.
FNrˆ   r%   s   &r   rƒ   ÚEvent.clearà   s   € ð
 ˆŽr   Nc                ón   <€ V ^8„  d   QhRS[ S[S[S[P                  3,          ,          RS[R,          /# )r   rM   r   N)r   r   rN   rO   rP   r   )r   r   s   "€r   r   r|   ç   s6   ø€ ÷ ñ Ù¡¡e©X×-?Ñ-?Ð&?Õ @ÕAðá	�4�ñr   c                ó,  a a€ \        4       oS P                  '       d   SP                  R4       S# S P                  P	                  S4       SP                  V 3R l4       Vf   S# \        P                  ! VS4      pVP                  V3R l4       V# )zxBlock until the internal flag is true.

Returns an awaitable, which raises `tornado.util.TimeoutError` after a
timeout.
Nc                 ó:   <€ SP                   P                  V 4      # r-   )r#   Úremove)r�   r&   s   &€r   rb   ÚEvent.wait.<locals>.<lambda>ô   s   ø€ ¨$¯-©-×*>Ñ*>¸sÔ*Cr   c                 óT   <€ SP                  4       '       g   SP                  4       # R # r-   )r.   Úcancel)Útfr�   s   &€r   rb   r–   ý   s   ø€ ¨s¯x©x¯zªz˜3Ÿ:™:›<ÐC¸tÐCr   )r   r~   rŒ   r#   Úaddrh   r   Úwith_timeout)r&   rM   Útimeout_futr�   s   f& @r   rj   Ú
Event.waitç   s~   ù€ ô ‹hˆØ�;�;ˆ;Ø�N‰N˜4Ô ØˆJØ�‰×Ñ˜#ÔØ×ÑÔCÔDØŠ?ØˆJä×*Ò*¨7°CÓ8ˆKð ×)Ñ)ÜCôð Ðr   )r~   r#   r-   )r5   r6   r7   r8   r9   r'   rI   r„   r   rƒ   rj   r:   r;   r<   s   @r   r   r   ž   sL   ø‡ € ñ%÷Nð ÷
ð 
÷ð ÷
)ð 
)÷ð ÷÷ ð r   c                   óZ   a € ] tR tRt o RtV 3R lR ltV 3R lR ltV 3R lR ltR	tV t	R
# )Ú_ReleasingContextManageri  z—Releases a Lock or Semaphore at the end of a "with" statement.

with (yield semaphore.acquire()):
    pass

# Now semaphore.release() has been called.
c                ó$   <€ V ^8„  d   QhRS[ RR/# )r   Úobjr   N)r
   )r   r   s   "€r   r   Ú%_ReleasingContextManager.__annotate__  s   ø€ ÷ ñ ™Cð  Dñ r   c                ó   € Wn         R # r-   ©Ú_obj)r&   r¡   s   &&r   r'   Ú!_ReleasingContextManager.__init__  s   € ØŽ	r   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r¢     s   ø€ ÷ ñ ˜4ñ r   c                ó   € R # r-   r   r%   s   &r   Ú	__enter__Ú"_ReleasingContextManager.__enter__  s   € Ùr   c                ób   <€ V ^8„  d   QhRRRS[ S[,          RS[ S[P                  ,          RR/# )r   Úexc_typeúOptional[Type[BaseException]]Úexc_valÚexc_tbr   N©r   ÚBaseExceptionÚtypesÚTracebackType)r   r   s   "€r   r   r¢     sC   ø€ ÷ ñ à1ðñ ™-Õ(ðñ ™×,Ñ,Õ-ð	ð
 
ñr   c                ó:   € V P                   P                  4        R # r-   )r¥   Úrelease)r&   r¬   r®   r¯   s   &&&&r   Ú__exit__Ú!_ReleasingContextManager.__exit__  s   € ð 	�	‰	×ÑÖr   r¤   N)
r5   r6   r7   r8   r9   r'   r©   r¶   r:   r;   r<   s   @r   rŸ   rŸ     s(   ø‡ € ñ÷ð ÷ð ÷ö r   rŸ   c                   óÎ   a a€ ] tR tRt oRtRV3R lV 3R llltV3R lV 3R lltV3R lR ltRV3R	 lR
 lltV3R lR lt	V3R lR lt
V3R lR ltV3R lR ltRtVtV ;t# )r   i  a®
  A lock that can be acquired a fixed number of times before blocking.

A Semaphore manages a counter representing the number of `.release` calls
minus the number of `.acquire` calls, plus an initial value. The `.acquire`
method blocks if necessary until it can return without making the counter
negative.

Semaphores limit access to a shared resource. To allow access for two
workers at a time:

.. testsetup:: semaphore

   from collections import deque

   from tornado import gen
   from tornado.ioloop import IOLoop
   from tornado.concurrent import Future

   inited = False

   async def simulator(futures):
       for f in futures:
           # simulate the asynchronous passage of time
           await gen.sleep(0)
           await gen.sleep(0)
           f.set_result(None)

   def use_some_resource():
       global inited
       global futures_q
       if not inited:
           inited = True
           # Ensure reliable doctest output: resolve Futures one at a time.
           futures_q = deque([Future() for _ in range(3)])
           IOLoop.current().add_callback(simulator, list(futures_q))

       return futures_q.popleft()

.. testcode:: semaphore

    import asyncio
    from tornado import gen
    from tornado.locks import Semaphore

    sem = Semaphore(2)

    async def worker(worker_id):
        await sem.acquire()
        try:
            print("Worker %d is working" % worker_id)
            await use_some_resource()
        finally:
            print("Worker %d is done" % worker_id)
            sem.release()

    async def runner():
        # Join all workers.
        await gen.multi([worker(i) for i in range(3)])

    asyncio.run(runner())

.. testoutput:: semaphore

    Worker 0 is working
    Worker 1 is working
    Worker 0 is done
    Worker 2 is working
    Worker 1 is done
    Worker 2 is done

Workers 0 and 1 are allowed to run concurrently, but worker 2 waits until
the semaphore has been released once, by worker 0.

The semaphore can be used as an async context manager::

    async def worker(worker_id):
        async with sem:
            print("Worker %d is working" % worker_id)
            await use_some_resource()

        # Now the semaphore has been released.
        print("Worker %d is done" % worker_id)

For compatibility with older versions of Python, `.acquire` is a
context manager, so ``worker`` could also be written as::

    @gen.coroutine
    def worker(worker_id):
        with (yield sem.acquire()):
            print("Worker %d is working" % worker_id)
            yield use_some_resource()

        # Now the semaphore has been released.
        print("Worker %d is done" % worker_id)

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

c                ó$   <€ V ^8„  d   QhRS[ RR/# ©r   Úvaluer   Nrn   )r   r   s   "€r   r   ÚSemaphore.__annotate__  s   ø€ ÷ ñ ™cð ¨$ñ r   c                óT   <€ \         SV `  4        V^ 8  d   \        R4      hWn        R# )r   z$semaphore initial value must be >= 0N)Úsuperr'   Ú
ValueErrorr~   ©r&   r»   rF   s   &&€r   r'   ÚSemaphore.__init__  s&   ø€ Ü‰ÑÔØ�1Œ9ÜÐCÓDÐDàŽr   c                ó    <€ V ^8„  d   QhRS[ /# r?   r@   )r   r   s   "€r   r   r¼   †  s   ø€ ÷ *ñ *™#ñ *r   c                óÔ   <€ \         SV `  4       pV P                  ^ 8X  d   RMRV P                   2pV P                  '       d   V R\	        V P                  4       2pRV^R  RV R2# )r   Úlockedzunlocked,value:z	,waiters:rD   z [z]>éÿÿÿÿ)r¾   rI   r~   r#   rG   )r&   ÚresÚextrarF   s   &  €r   rI   ÚSemaphore.__repr__†  sk   ø€ Ü‰gÑÓ ˆØ ŸK™K¨1Ô,‘°OÀDÇKÁKÀ=Ð2QˆØ�=�=ˆ=Ø�g˜Y¤s¨4¯=©=Ó'9Ð&:Ð;ˆEØ�3�q˜�9�+˜R ˜w bÐ)Ð)r   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r¼   �  s   ø€ ÷ ñ ˜ñ r   c                ó*  € V ;P                   ^,          un         V P                  '       dh   V P                  P                  4       pVP                  4       '       d   KD  V ;P                   ^,          un         VP	                  \        V 4      4       R# R# )ú*Increment the counter and wake one waiter.N)r~   r#   rq   r.   rŒ   rŸ   rW   s   & r   rµ   ÚSemaphore.release�  sb   € à�Š�qÕ�Ø�m�mˆmØ—]‘]×*Ñ*Ó,ˆFØ—;‘;—=”=Ø—’˜qÕ •ð ×!Ñ!Ô":¸4Ó"@ÔAÙñ r   c                óp   <€ V ^8„  d   QhRS[ S[S[S[P                  3,          ,          RS[S[,          /# rL   ©r   r   rN   rO   rP   r   rŸ   )r   r   s   "€r   r   r¼   ž  s8   ø€ ÷ ñ Ù¡¡e©X×-?Ñ-?Ð&?Õ @ÕAðá	Ñ+Õ	,ñr   c                ó’  a aaa€ \        4       oS P                  ^ 8”  d6   S ;P                  ^,          un        SP                  \        S 4      4       S# S P                  P                  S4       V'       dP   R V V3R llp\        P                  P                  4       oSP                  W4      oSP                  VV3R l4       S# )zŸDecrement the counter. Returns an awaitable.

Block if the counter is zero and wait for a `.release`. The awaitable
raises `.TimeoutError` after the deadline.
c                ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   Ú'Semaphore.acquire.<locals>.__annotate__®  s   € ÷ ,ñ , Dñ ,r   c                  óœ   <€ SP                  4       '       g%   SP                  \        P                  ! 4       4       S P	                  4        R # r-   )r.   Úset_exceptionr   ÚTimeoutErrorr3   rW   s   €€r   rY   Ú%Semaphore.acquire.<locals>.on_timeout®  s1   ø€ Ø!Ÿ;™;Ÿ=š=Ø×,Ñ,¬S×-=Ò-=Ó-?Ô@Ø×)Ñ)Ö+r   c                 ó&   <€ SP                  S4      # r-   r\   r^   s   &€€r   rb   Ú#Semaphore.acquire.<locals>.<lambda>¶  s   ø€ ˜g×4Ñ4°^ÔDr   )r   r~   rŒ   rŸ   r#   rd   r   re   rf   rg   rh   ri   s   f& @@@r   ÚacquireÚSemaphore.acquirež  s�   û€ ô “ˆØ�;‰;˜Œ?Ø�KŠK˜1Õ�KØ×ÑÔ6°tÓ<Ô=ð ˆð �M‰M× Ñ  Ô(ß÷,ñ ,ô
 !Ÿ-™-×/Ñ/Ó1�Ø!(×!4Ñ!4°WÓ!I�Ø×(Ñ(ÝDôð ˆr   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r¼   º  s   ø€ ÷ Oñ O˜4ñ Or   c                ó   € \        R 4      h)z0Use 'async with' instead of 'with' for Semaphore©ÚRuntimeErrorr%   s   &r   r©   ÚSemaphore.__enter__º  s   € ÜÐMÓNÐNr   c                ób   <€ V ^8„  d   QhRRRS[ S[,          RS[ S[P                  ,          RR/# )r   Útypr­   r»   Ú	tracebackr   Nr°   )r   r   s   "€r   r   r¼   ½  sC   ø€ ÷ ñ à,ðñ ™Õ&ðñ ™E×/Ñ/Õ0ð	ð
 
ñr   c                ó&   € V P                  4        R # r-   ©r©   )r&   rà   r»   rá   s   &&&&r   r¶   ÚSemaphore.__exit__½  ó   € ð 	�‰Ör   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r¼   Å  ó   ø€ ÷ ñ  $ñ r   c              ƒ  óB   "  € V P                  4       G R j  x€L
  R #  L5ir-   ©rØ   r%   s   &r   Ú
__aenter__ÚSemaphore.__aenter__Å  ó   é € Ø�l‰l‹n×Ôùó   ‚–—c                ób   <€ V ^8„  d   QhRRRS[ S[,          RS[ S[P                  ,          RR/# ©r   rà   r­   r»   Útbr   Nr°   )r   r   s   "€r   r   r¼   È  óC   ø€ ÷ ñ à,ðñ ™Õ&ðñ ‘U×(Ñ(Õ)ð	ð
 
ñr   c              ƒ  ó.   "  € V P                  4        R # 5ir-   ©rµ   ©r&   rà   r»   rð   s   &&&&r   Ú	__aexit__ÚSemaphore.__aexit__È  ó   é € ð 	�‰Žùó   ‚rˆ   ry   r-   )r5   r6   r7   r8   r9   r'   rI   rµ   rØ   r©   r¶   rê   rõ   r:   r;   Ú__classcell__©rF   r   s   @@r   r   r     sc   ù‡ € ñb÷Hõ ÷*ó *÷ð ÷"ò ÷8Oð O÷ð ÷ð ÷÷ ð r   c                   ó^   a a€ ] tR tRt oRtRV3R lV 3R llltV3R lV 3R lltRtVtV ;t	# )	r   iÑ  a&  A semaphore that prevents release() being called too many times.

If `.release` would increment the semaphore's value past the initial
value, it raises `ValueError`. Semaphores are mostly used to guard
resources with limited capacity, so a semaphore released too many times
is a sign of a bug.
c                ó$   <€ V ^8„  d   QhRS[ RR/# rº   rn   )r   r   s   "€r   r   ÚBoundedSemaphore.__annotate__Ú  s   ø€ ÷ $ñ $™cð $¨$ñ $r   c                ó4   <€ \         SV `  VR 7       Wn        R# )©r»   N)r¾   r'   Ú_initial_valuerÀ   s   &&€r   r'   ÚBoundedSemaphore.__init__Ú  s   ø€ Ü‰Ñ˜uÐÔ%Ø#Ör   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   rý   Þ  s   ø€ ÷ ñ ˜ñ r   c                óp   <€ V P                   V P                  8¼  d   \        R4      h\        SV `  4        R# )rË   z!Semaphore released too many timesN)r~   r   r¿   r¾   rµ   )r&   rF   s   &€r   rµ   ÚBoundedSemaphore.releaseÞ  s+   ø€ à�;‰;˜$×-Ñ-Ô-ÜÐ@ÓAÐAÜ‰‰Ör   )r   ry   )
r5   r6   r7   r8   r9   r'   rµ   r:   r;   rù   rú   s   @@r   r   r   Ñ  s#   ù‡ € ñ÷$õ $÷÷ ó r   c                   ó¸   a € ] tR tRt o RtV 3R lR ltV 3R lR ltRV 3R lR	 lltV 3R
 lR ltV 3R lR lt	V 3R lR lt
V 3R lR ltV 3R lR ltRtV tR# )r   iå  ag  A lock for coroutines.

A Lock begins unlocked, and `acquire` locks it immediately. While it is
locked, a coroutine that yields `acquire` waits until another coroutine
calls `release`.

Releasing an unlocked lock raises `RuntimeError`.

A Lock can be used as an async context manager with the ``async
with`` statement:

>>> from tornado import locks
>>> lock = locks.Lock()
>>>
>>> async def f():
...    async with lock:
...        # Do something holding the lock.
...        pass
...
...    # Now the lock is released.

For compatibility with older versions of Python, the `.acquire`
method asynchronously returns a regular context manager:

>>> async def f2():
...    with (yield lock.acquire()):
...        # Do something holding the lock.
...        pass
...
...    # Now the lock is released.

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

c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   ÚLock.__annotate__
  s   ø€ ÷ 0ñ 0˜$ñ 0r   c                ó(   € \        ^R7      V n        R# )r+   rÿ   N)r   Ú_blockr%   s   &r   r'   ÚLock.__init__
  s   € Ü&¨QÔ/ˆŽr   c                ó    <€ V ^8„  d   QhRS[ /# r?   r@   )r   r   s   "€r   r   r    s   ø€ ÷ Cñ C™#ñ Cr   c                óP   € R V P                   P                   RV P                   R2# )rD   z _block=rE   )rF   r5   r	  r%   s   &r   rI   ÚLock.__repr__  s&   € Ø�4—>‘>×*Ñ*Ð+¨8°D·K±K°=ÀÐBÐBr   Nc                óp   <€ V ^8„  d   QhRS[ S[S[S[P                  3,          ,          RS[S[,          /# rL   rÎ   )r   r   s   "€r   r   r    s8   ø€ ÷ ,ñ ,Ù¡¡e©X×-?Ñ-?Ð&?Õ @ÕAð,á	Ñ+Õ	,ñ,r   c                ó8   € V P                   P                  V4      # )zxAttempt to lock. Returns an awaitable.

Returns an awaitable, which raises `tornado.util.TimeoutError` after a
timeout.
)r	  rØ   )r&   rM   s   &&r   rØ   ÚLock.acquire  s   € ð �{‰{×"Ñ" 7Ó+Ð+r   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r    s   ø€ ÷ 
8ñ 
8˜ñ 
8r   c                óp   €  V P                   P                  4        R#   \         d    \        R4      hi ; i)zrUnlock.

The first coroutine in line waiting for `acquire` gets the lock.

If not locked, raise a `RuntimeError`.
zrelease unlocked lockN)r	  rµ   r¿   rÝ   r%   s   &r   rµ   ÚLock.release  s2   € ð	8Ø�K‰K×ÑÖ!øÜô 	8ÜÐ6Ó7Ð7ð	8ús   ‚ ž5c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r  &  s   ø€ ÷ Jñ J˜4ñ Jr   c                ó   € \        R 4      h)z+Use `async with` instead of `with` for LockrÜ   r%   s   &r   r©   ÚLock.__enter__&  s   € ÜÐHÓIÐIr   c                ób   <€ V ^8„  d   QhRRRS[ S[,          RS[ S[P                  ,          RR/# rï   r°   )r   r   s   "€r   r   r  )  sC   ø€ ÷ ñ à,ðñ ™Õ&ðñ ‘U×(Ñ(Õ)ð	ð
 
ñr   c                ó&   € V P                  4        R # r-   rã   rô   s   &&&&r   r¶   ÚLock.__exit__)  rå   r   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r  1  rç   r   c              ƒ  óB   "  € V P                  4       G R j  x€L
  R #  L5ir-   ré   r%   s   &r   rê   ÚLock.__aenter__1  rì   rí   c                ób   <€ V ^8„  d   QhRRRS[ S[,          RS[ S[P                  ,          RR/# rï   r°   )r   r   s   "€r   r   r  4  rñ   r   c              ƒ  ó.   "  € V P                  4        R # 5ir-   ró   rô   s   &&&&r   rõ   ÚLock.__aexit__4  r÷   rø   )r	  r-   )r5   r6   r7   r8   r9   r'   rI   rØ   rµ   r©   r¶   rê   rõ   r:   r;   r<   s   @r   r   r   å  s_   ø‡ € ñ"÷H0ð 0÷Cð C÷,ò ,÷
8ð 
8÷Jð J÷ð ÷ð ÷ö r   )r   r   r   r   r   )r!   rO   r²   Útornador   r   Útornado.concurrentr   r   Útypingr   r   r	   r
   r   ÚTYPE_CHECKINGr   r   Ú__all__r   r   r   rŸ   r   r   r   r   r   r   Ú<module>r%     sŽ   ðó Û Û ç ß Iç 8Õ 8Û à	××Ðß!â
I€÷Xñ Xô,f(Ð(ô f(÷Rañ a÷Hñ ô0tÐ(ô tôn�yô ÷(Uó Ur   