ó
    F\hM7  ã                   ón  • S r SrSSKrSSKrSSKrSSKrSSKJr  SSK	J
r
  SSK	Jr  SSK	Jr  SS	K	Jr  \
R                  r\
R                  r\
R                   r\
R"                  r\R$                  S-
  r " S
 S5      r\rS rS rS rS rS rS rSS.S jr SSKr\R(                  =rrg! \ a     gf = f)z.A Future class similar to the one in PEP 3148.)ÚFutureÚwrap_futureÚisfutureé    N)ÚGenericAliasé   )Úbase_futures)Úevents)Ú
exceptions)Úformat_helpersc                   óø   • \ rS rSrSr\rSrSrSr	Sr
SrSrSrSrSS.S jrS rS r\" \5      r\S	 5       r\R.                  S
 5       rS rS rSS jrS rS rS rS rS rSS.S jr S r!S r"S r#S r$\$r%Sr&g)r   é   a  This class is *almost* compatible with concurrent.futures.Future.

Differences:

- This class is not thread-safe.

- result() and exception() do not take a timeout argument and
  raise an exception when the future isn't done yet.

- Callbacks registered with add_done_callback() are always called
  via the event loop's call_soon().

- This class is not compatible with the wait() and as_completed()
  methods in the concurrent.futures package.

(In Python 3.4 or later we may be able to unify the implementations.)
NF©Úloopc                óø   • Uc  [         R                  " 5       U l        OXl        / U l        U R                  R	                  5       (       a0  [
        R                  " [        R                  " S5      5      U l	        gg)z»Initialize the future.

The optional event_loop argument allows explicitly setting the event
loop object used by the future. If it's not provided, the future uses
the default event loop.
Nr   )
r	   Úget_event_loopÚ_loopÚ
_callbacksÚ	get_debugr   Úextract_stackÚsysÚ	_getframeÚ_source_traceback©Úselfr   s     Ú&/usr/lib/python3.13/asyncio/futures.pyÚ__init__ÚFuture.__init__H   s\   € ð ‰<Ü×.Ò.Ó0ˆD�JàŒJØˆŒØ�:‰:×Ñ×!Ñ!Ü%3×%AÒ%AÜ—’˜aÓ ó&"ˆDÕ"ð "ó    c                 ó.   • [         R                  " U 5      $ ©N)r   Ú_future_repr©r   s    r   Ú__repr__ÚFuture.__repr__X   s   € Ü×(Ò(¨Ó.Ð.r   c                 óð   • U R                   (       d  g U R                  nU R                  R                   S3UU S.nU R                  (       a  U R                  US'   U R
                  R                  U5        g )Nz exception was never retrieved)ÚmessageÚ	exceptionÚfutureÚsource_traceback)Ú_Future__log_tracebackÚ
_exceptionÚ	__class__Ú__name__r   r   Úcall_exception_handler)r   ÚexcÚcontexts      r   Ú__del__ÚFuture.__del__[   sl   € Ø×#×#ð Ø�o‰oˆð —>‘>×*Ñ*Ð+Ð+IÐJØØñ	
ˆð ×!×!Ø*.×*@Ñ*@ˆGÐ&Ñ'Ø�
‰
×)Ñ)¨'Õ2r   c                 ó   • U R                   $ r    )r*   r"   s    r   Ú_log_tracebackÚFuture._log_tracebackm   s   € à×#Ñ#Ð#r   c                 ó6   • U(       a  [        S5      eSU l        g )Nz'_log_traceback can only be set to FalseF)Ú
ValueErrorr*   )r   Úvals     r   r4   r5   q   s   € æÜÐFÓGÐGØ$ˆÕr   c                 ó:   • U R                   nUc  [        S5      eU$ )z-Return the event loop the Future is bound to.z!Future object is not initialized.)r   ÚRuntimeErrorr   s     r   Úget_loopÚFuture.get_loopw   s!   € à�z‰zˆØ‰<ÜÐBÓCÐCØˆr   c                 óÒ   • U R                   b  U R                   nSU l         U$ U R                  c  [        R                  " 5       nU$ [        R                  " U R                  5      nU$ )z°Create the CancelledError to raise if the Future is cancelled.

This should only be called once when handling a cancellation since
it erases the saved context exception value.
N)Ú_cancelled_excÚ_cancel_messager
   ÚCancelledError)r   r/   s     r   Ú_make_cancelled_errorÚFuture._make_cancelled_error~   sf   € ð ×ÑÑ*Ø×%Ñ%ˆCØ"&ˆDÔØˆJà×ÑÑ'Ü×+Ò+Ó-ˆCð ˆ
ô ×+Ò+¨D×,@Ñ,@ÓAˆCØˆ
r   c                 ó~   • SU l         U R                  [        :w  a  g[        U l        Xl        U R                  5         g)zÁCancel the future and schedule callbacks.

If the future is already done or cancelled, return False.  Otherwise,
change the future's state to cancelled, schedule the callbacks and
return True.
FT)r*   Ú_stateÚ_PENDINGÚ
_CANCELLEDr?   Ú_Future__schedule_callbacks)r   Úmsgs     r   ÚcancelÚFuture.cancel�   s7   € ð  %ˆÔØ�;‰;œ(Ó"ØÜ ˆŒØ"ÔØ×!Ñ!Ô#Ør   c                 óš   • U R                   SS nU(       d  g/ U R                   SS& U H  u  p#U R                  R                  X US9  M!     g)z’Internal: Ask the event loop to call all callbacks.

The callbacks are scheduled to be called as soon as possible. Also
clears the callback list.
N©r0   )r   r   Ú	call_soon)r   Ú	callbacksÚcallbackÚctxs       r   Ú__schedule_callbacksÚFuture.__schedule_callbacksž   sI   € ð —O‘O¡AÐ&ˆ	ÞØàˆ�‰™ÐÛ&‰MˆHØ�J‰J× Ñ  ¸Ð Ó=ò 'r   c                 ó(   • U R                   [        :H  $ )z(Return True if the future was cancelled.)rD   rF   r"   s    r   Ú	cancelledÚFuture.cancelled¬   s   € à�{‰{œjÑ(Ð(r   c                 ó(   • U R                   [        :g  $ )z�Return True if the future is done.

Done means either that a result / exception are available, or that the
future was cancelled.
)rD   rE   r"   s    r   ÚdoneÚFuture.done²   s   € ð �{‰{œhÑ&Ð&r   c                 ó(  • U R                   [        :X  a  U R                  5       eU R                   [        :w  a  [        R
                  " S5      eSU l        U R                  b%  U R                  R                  U R                  5      eU R                  $ )zöReturn the result this future represents.

If the future has been cancelled, raises CancelledError.  If the
future's result isn't yet available, raises InvalidStateError.  If
the future is done and has an exception set, this exception is raised.
zResult is not ready.F)rD   rF   rA   Ú	_FINISHEDr
   ÚInvalidStateErrorr*   r+   Úwith_tracebackÚ_exception_tbÚ_resultr"   s    r   ÚresultÚFuture.resultº   st   € ð �;‰;œ*Ó$Ø×,Ñ,Ó.Ð.Ø�;‰;œ)Ó#Ü×.Ò.Ð/EÓFÐFØ$ˆÔØ�?‰?Ñ&Ø—/‘/×0Ñ0°×1CÑ1CÓDÐDØ�|‰|Ðr   c                 óÄ   • U R                   [        :X  a  U R                  5       eU R                   [        :w  a  [        R
                  " S5      eSU l        U R                  $ )zþReturn the exception that was set on this future.

The exception (or None if no exception was set) is returned only if
the future is done.  If the future has been cancelled, raises
CancelledError.  If the future isn't done yet, raises
InvalidStateError.
zException is not set.F)rD   rF   rA   rZ   r
   r[   r*   r+   r"   s    r   r'   ÚFuture.exceptionÊ   sO   € ð �;‰;œ*Ó$Ø×,Ñ,Ó.Ð.Ø�;‰;œ)Ó#Ü×.Ò.Ð/FÓGÐGØ$ˆÔØ�‰Ðr   rL   c                óÊ   • U R                   [        :w  a  U R                  R                  XUS9  gUc  [        R
                  " 5       nU R                  R                  X45        g)zØAdd a callback to be run when the future becomes done.

The callback is called with a single argument - the future object. If
the future is already done when this is called, the callback is
scheduled with call_soon.
rL   N)rD   rE   r   rM   ÚcontextvarsÚcopy_contextr   Úappend)r   Úfnr0   s      r   Úadd_done_callbackÚFuture.add_done_callbackÙ   sN   € ð �;‰;œ(Ó"Ø�J‰J× Ñ  °7Ð Ò;à‰Ü%×2Ò2Ó4�Ø�O‰O×"Ñ" B =Õ1r   c                 óÎ   • U R                    VVs/ s H  u  p#X!:w  d  M  X#4PM     nnn[        U R                   5      [        U5      -
  nU(       a  X@R                   SS& U$ s  snnf )zmRemove all instances of a callback from the "call when done" list.

Returns the number of callbacks removed.
N)r   Úlen)r   rg   ÚfrP   Úfiltered_callbacksÚremoved_counts         r   Úremove_done_callbackÚFuture.remove_done_callbacké   sh   € ð /3¯oªoô*Ú.=¡( 1Ø!"¡ó '˜q›hÙ.=ð 	ñ *ô ˜DŸO™OÓ,¬sÐ3EÓ/FÑFˆÞØ!3�O‰O™AÐØÐùó*s
   �A!ŸA!c                 óº   • U R                   [        :w  a&  [        R                  " U R                    SU < 35      eXl        [
        U l         U R                  5         g)z~Mark the future done and set its result.

If the future is already done when this method is called, raises
InvalidStateError.
ú: N)rD   rE   r
   r[   r^   rZ   rG   )r   r_   s     r   Ú
set_resultÚFuture.set_resultø   sH   € ð �;‰;œ(Ó"Ü×.Ò.°$·+±+°¸bÀÁÐ/IÓJÐJØŒÜˆŒØ×!Ñ!Õ#r   c                 ó~  • U R                   [        :w  a&  [        R                  " U R                    SU < 35      e[	        U[
        5      (       a  U" 5       n[	        U[        5      (       a  [        S5      nXl        Xl	        UnXl
        UR                  U l        [        U l         U R                  5         SU l        g)z€Mark the future done and set an exception.

If the future is already done when this method is called, raises
InvalidStateError.
rr   zPStopIteration interacts badly with generators and cannot be raised into a FutureTN)rD   rE   r
   r[   Ú
isinstanceÚtypeÚStopIterationr:   Ú	__cause__Ú__context__r+   Ú__traceback__r]   rZ   rG   r*   )r   r'   Únew_excs      r   Úset_exceptionÚFuture.set_exception  s¡   € ð �;‰;œ(Ó"Ü×.Ò.°$·+±+°¸bÀÁÐ/IÓJÐJÜ�i¤×&Ñ&Ù!›ˆIÜ�i¤×/Ñ/Ü"ð $,ó -ˆGð !*ÔØ"+ÔØˆIØ#ŒØ&×4Ñ4ˆÔÜˆŒØ×!Ñ!Ô#Ø#ˆÕr   c              #   óª   #   • U R                  5       (       d  SU l        U v •  U R                  5       (       d  [        S5      eU R                  5       $ 7f)NTzawait wasn't used with future)rW   Ú_asyncio_future_blockingr:   r_   r"   s    r   Ú	__await__ÚFuture.__await__  s@   é € Ø�y‰y�{‰{Ø,0ˆDÔ)ØŠJØ�y‰y�{‰{ÜÐ>Ó?Ð?Ø�{‰{‹}Ðùs   ‚AA)Ú__log_tracebackr€   r   r?   r>   r+   r]   r   r^   r   rD   r    )'r-   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rE   rD   r^   r+   r   r   r?   r>   r€   r*   r   r#   r1   Úclassmethodr   Ú__class_getitem__Úpropertyr4   Úsetterr;   rA   rI   rG   rT   rW   r_   r'   rh   ro   rs   r}   r�   Ú__iter__Ú__static_attributes__© r   r   r   r      sÒ   † ñð& €FØ€GØ€JØ€EØÐØ€Oà€Nð  %Ðà€Oà#õ "ò /ò3ñ  $ LÓ1Ðàñ$ó ð$ð ×Ññ%ó ð%ò
òô"ò>ò)ò'òò ð 04õ 2ò ò
$ò$ò.ð ƒHr   r   c                 ó`   •  U R                   nU" 5       $ ! [         a     U R                  $ f = fr    )r;   ÚAttributeErrorr   )Úfutr;   s     r   Ú	_get_loopr’   *  s:   € ðØ—<‘<ˆñ ‹zÐøô ó Øð �9‰9Ðð	ús   ‚ •
-¬-c                 óR   • U R                  5       (       a  gU R                  U5        g)z?Helper setting the result only if the future was not cancelled.N)rT   rs   )r‘   r_   s     r   Ú_set_result_unless_cancelledr”   6  s   € à
‡}�}‡�ØØ‡N�N�6Õr   c                 óh  • [        U 5      nU[        R                  R                  L a6  [        R                  " U R
                  6 R                  U R                  5      $ U[        R                  R                  L a6  [        R                  " U R
                  6 R                  U R                  5      $ U $ r    )	rw   Ú
concurrentÚfuturesr@   r
   Úargsr\   r{   r[   )r/   Ú	exc_classs     r   Ú_convert_future_excrš   =  s„   € Ü�S“	€IØ”J×&Ñ&×5Ñ5Ò5Ü×(Ò(¨#¯(©(Ð3×BÑBÀ3×CTÑCTÓUÐUØ	”j×(Ñ(×:Ñ:Ò	:Ü×+Ò+¨S¯X©XÐ6×EÑEÀc×FWÑFWÓXÐXàˆ
r   c                 óN  • UR                  5       (       d   eUR                  5       (       a  U R                  " 5         U R                  " 5       (       d  gUR	                  5       nUb  U R
                  " [        U5      5        gUR                  5       nU R                  " U5        g)z8Copy state from a future to a concurrent.futures.Future.N)	rW   rT   rI   Úset_running_or_notify_cancelr'   r}   rš   r_   rs   )r–   Úsourcer'   r_   s       r   Ú_set_concurrent_future_staterž   G  s€   € à�;‰;�=‰=Ðˆ=Ø×Ñ×ÑØ×ÒÔØ×2Ò2×4Ñ4ØØ× Ñ Ó"€IØÑØ× Ò Ô!4°YÓ!?Õ@à—‘“ˆØ×Ò˜fÕ%r   c                 óv  • U R                  5       (       d   eUR                  5       (       a  gUR                  5       (       a   eU R                  5       (       a  UR                  5         gU R                  5       nUb  UR	                  [        U5      5        gU R                  5       nUR                  U5        g)ziInternal helper to copy state from another Future.

The other Future may be a concurrent.futures.Future.
N)rW   rT   rI   r'   r}   rš   r_   rs   )r�   Údestr'   r_   s       r   Ú_copy_future_stater¡   V  s‹   € ð
 �;‰;�=‰=Ðˆ=Ø‡~�~×ÑØØ�y‰y�{‰{Ðˆ?Ø×Ñ×ÑØ�‰�à×$Ñ$Ó&ˆ	ØÑ Ø×ÑÔ2°9Ó=Õ>à—]‘]“_ˆFØ�O‰O˜FÕ#r   c                 óþ  ^ ^^^^• [        T 5      (       d4  [        T [        R                  R                  5      (       d  [        S5      e[        T5      (       d4  [        T[        R                  R                  5      (       d  [        S5      e[        T 5      (       a  [        T 5      OSm[        T5      (       a  [        T5      OSmS mUU U4S jnUUUU4S jnTR                  U5        T R                  U5        g)a   Chain two futures so that when one completes, so does the other.

The result (or exception) of source will be copied to destination.
If destination is cancelled, source gets cancelled too.
Compatible with both asyncio.Future and concurrent.futures.Future.
z(A future is required for source argumentz-A future is required for destination argumentNc                 óR   • [        U 5      (       a  [        X5        g [        X5        g r    )r   r¡   rž   )r(   Úothers     r   Ú
_set_stateÚ!_chain_future.<locals>._set_statez  s   € Ü�F×ÑÜ˜uÕ-ä(¨Õ7r   c                 óš   >• U R                  5       (       a5  Tb  TTL a  TR                  5         g TR                  TR                  5        g g r    )rT   rI   Úcall_soon_threadsafe)ÚdestinationÚ	dest_loopr�   Úsource_loops    €€€r   Ú_call_check_cancelÚ)_chain_future.<locals>._call_check_cancel€  s?   ø€ Ø× Ñ ×"Ñ"ØÑ" k°YÒ&>Ø—‘•à×0Ñ0°·±Õ?ð	 #r   c                 óØ   >• TR                  5       (       a  Tb  TR                  5       (       a  g Tb  TTL a
  T" TU 5        g TR                  5       (       a  g TR                  TTU 5        g r    )rT   Ú	is_closedr¨   )r�   r¥   rª   r©   r«   s    €€€€r   Ú_call_set_stateÚ&_chain_future.<locals>._call_set_state‡  sd   ø€ Ø×!Ñ!×#Ñ#ØÑ%¨)×*=Ñ*=×*?Ñ*?ØØÑ 	¨[Ò 8Ù�{ FÕ+à×"Ñ"×$Ñ$ØØ×*Ñ*¨:°{ÀFÕKr   )r   rv   r–   r—   r   Ú	TypeErrorr’   rh   )r�   r©   r¬   r°   r¥   rª   r«   s   ``  @@@r   Ú_chain_futurer³   j  sÓ   ü€ ô �F×Ñ¤J¨vÜ/9×/AÑ/A×/HÑ/H÷%Jñ %JäÐBÓCÐCÜ�K× Ñ ¬°KÜ4>×4FÑ4F×4MÑ4M÷*Oñ *OäÐGÓHÐHÜ'/°×'7Ñ'7”)˜FÔ#¸T€KÜ*2°;×*?Ñ*?”	˜+Ô&ÀT€Iò8÷@÷	Lð 	Lð ×!Ñ!Ð"4Ô5Ø
×Ñ˜_Õ-r   r   c                óø   • [        U 5      (       a  U $ [        U [        R                  R                  5      (       d   SU < 35       eUc  [
        R                  " 5       nUR                  5       n[        X5        U$ )z&Wrap concurrent.futures.Future object.z+concurrent.futures.Future is expected, got )	r   rv   r–   r—   r   r	   r   Úcreate_futurer³   )r(   r   Ú
new_futures      r   r   r   –  ss   € ä�×ÑØˆÜ�fœj×0Ñ0×7Ñ7×8Ñ8ð AØ
5°f±ZÐ@óAÐ8à�|Ü×$Ò$Ó&ˆØ×#Ñ#Ó%€JÜ�&Ô%ØÐr   ) r‡   Ú__all__Úconcurrent.futuresr–   rd   Úloggingr   Útypesr   Ú r   r	   r
   r   r   rE   rF   rZ   ÚDEBUGÚSTACK_DEBUGr   Ú	_PyFuturer’   r”   rš   rž   r¡   r³   r   Ú_asyncioÚ_CFutureÚImportErrorrŽ   r   r   Ú<module>rÂ      sÕ   ðÙ 4ð€ó Û Û Û 
Ý å Ý Ý Ý ð × Ñ €ð × Ñ €Ø×$Ñ$€
Ø×"Ñ"€	ð �m‰m˜aÑ€÷Eñ EðR €	ò	òòò&ò$ò().ðX !%õ 
ð(Ûð
 !Ÿ™Ð'€F‰Xøð	 ó 	Ùð	ús   ÂB+ Â+B4Â3B4