
    hn                   :   % S r SSKJr  SSKrSSKrSSKrSSKJrJr  SSK	J
r
JrJr  SSKJrJr  SSKJr  SSKJr  SS	KJrJr  SS
KJrJrJrJr  SSKJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0J1r1  SSK2r2SSK3J4r4  SSK5J6r6J7r7J8r8J9r9  SSK:J;r;J<r<  SSK=J>r>  SSK?J@r@  SSKAJBrBJCrCJDrD  SSKEJFrFJGrGJHrH  SSKIJJrJJKrK  \>" 5       rL\." S5      rM\8" S5      rN\B=(       a    \R                  S:  rP " S S\Q5      rR " S S\Q5      rS " S S\Q5      rT " S S\U5      rVSnS jrWSoS  jrXSpSqS! jjrY        SrS" jrZ\1        SsS# j5       r[\1        StS$ j5       r[\1        SuS% j5       r[        SvS& jr[\F" \4" S'S(S)S5      S*S+9SwS, j5       r\SxS- jr]SyS. jr^SzS/ jr_S{S0 jr`S|S1 jra " S2 S3\5      rb\bR                  rc\bR                  rd\"S4\e4   rf\"S4\e4   rg\,\eS44   rh\(\i\e4   rj\,\,\/\f\7\bR                     4   \h\j4   \,\/\g\f\7\bR                     4   \h\j4   4   rk\" 0 5      rlS5\mS6'   \." S75      rn\." S85      ro " S9 S:5      rp " S; S<\!\n   5      rq\q/rr    S}S= jrs\D " S> S?\Q5      5       rt\,\n\u4   rv\,\w\n4   rx\'\x\n      ry\(       aD  \1  S~         SSA jj5       rz\1   S         SSB jj5       rz   S         SSC jjrz\zr{ " SD SE\q\y\       5      r{ S     SSF jjr| S     SSG jjr} " SH SI\Q5      r~SSJ jrSKrS@r " SL SM\5      r\F" \4" S'SNSOS5      SPS+9SSQ j5       r\2GR
                  " SKSR9 " SS ST\%\n   5      5       r            SSU jr\K          SSV j5       r      SSW jr      SSX jr    SSY jr " SZ S[\Q5      r    SS\ jr " S] S^\5      r " S_ S`\5      r " Sa Sb\5      r " Sc Sd\Q5      r " Se Sf\Q5      r " Sg Sh\%\M   5      r " Si Sj\Q5      r " Sk Sl\@GR*                  5      r/ SmQrg)zU
Support for results that aren't immediately available.

Maintainer: Glyph Lefkowitz
    )annotationsN)ABCabstractmethod)AbstractEventLoopFutureiscoroutine)Contextcopy_context)Enumwraps)exc_infoimplementation)CoroutineTypeGeneratorTypeMappingProxyTypeTracebackType)TYPE_CHECKINGAny	AwaitableCallable	Coroutine	GeneratorGenericIterableListMappingNoReturnOptionalSequenceTupleTypeTypeVarUnioncastoverload)Version)ConcatenateLiteral	ParamSpecSelf)IDelayedCallIReactorTime)Logger)lockfile)_PYPYcmp
comparable)
deprecateddeprecatedPropertywarnAboutFunction)Failure_extraneous_T_P)         c                      \ rS rSrSrSrg)AlreadyCalledErrorA   z
This error is raised when one of L{Deferred.callback} or L{Deferred.errback}
is called after one of the two had already been called.
 N__name__
__module____qualname____firstlineno____doc____static_attributes__r@       ]/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/internet/defer.pyr>   r>   A       rH   r>   c                      \ rS rSrSrSrg)CancelledErrorH   zB
This error is raised by default when a L{Deferred} is cancelled.
r@   NrA   r@   rH   rI   rL   rL   H       rH   rL   c                      \ rS rSrSrSrg)TimeoutErrorN   z?
This error is raised by default when a L{Deferred} times out.
r@   NrA   r@   rH   rI   rP   rP   N   rN   rH   rP   c                      \ rS rSrSrSrg)NotACoroutineErrorT   zV
This error is raised when a coroutine is expected and something else is
encountered.
r@   NrA   r@   rH   rI   rS   rS   T   rJ   rH   rS   c                2    [         R                  SU 5        U $ )a  
Log and return failure.

This method can be used as an errback that passes the failure on to the
next errback unmodified. Note that if this is the last errback, and the
deferred gets garbage collected after being this errback has been called,
the clean up code logs it again.
 )logfailure)errs    rI   logErrorrZ   [   s     KKCJrH   c                B    [        5       nXl        SUl        SUl        U$ )a  
Return a L{Deferred} that has already had C{.callback(result)} called.

This is useful when you're writing synchronous code to an
asynchronous interface: i.e., some code is calling you expecting a
L{Deferred} result, but you don't actually need to do anything
asynchronous. Just return C{defer.succeed(theResult)}.

See L{fail} for a version of this function that uses a failing
L{Deferred} rather than a successful one.

@param result: The result to give to the Deferred's 'callback'
       method.
TN)Deferredresultcalled
_chainedTor]   ds     rI   succeedrb   h   s%     jA HAHALHrH   c                <    [        5       nUR                  U 5        U$ )a  
Return a L{Deferred} that has already had C{.errback(result)} called.

See L{succeed}'s docstring for rationale.

@param result: The same argument that L{Deferred.errback} takes.

@raise NoCurrentExceptionError: If C{result} is L{None} but there is no
    current exception state.
)r\   errbackr`   s     rI   failre      s      zAIIfHrH   c                ^     U " U0 UD6n[        U5      $ ! [         a    [        5       s $ f = f)a  
Create a L{Deferred} from a callable and arguments.

Call the given function with the given arguments.  Return a L{Deferred}
which has been fired with its callback as the result of that invocation
or its C{errback} with a L{Failure} for the exception thrown.
)rb   BaseExceptionre   )callableargskwargsr]   s       rI   executerk      s:    4*6* v  vs    ,,c                    g Nr@   fri   rj   s      rI   maybeDeferredrp           rH   c                    g rm   r@   rn   s      rI   rp   rp      s     rH   c                    g rm   r@   rn   s      rI   rp   rp      rq   rH   c                F    U " U0 UD6n[        U5      [        ;   a  U$ [        U[        5      (       a  [        U5      $ [        U5      [        L a  [        R                  U5      $ Un[        U5      $ ! [          a#    [        [        [        R                  S95      s $ f = f)a  
Invoke a function that may or may not return a L{Deferred} or coroutine.

Call the given function with the given arguments.  Then:

  - If the returned object is a L{Deferred}, return it.

  - If the returned object is a L{Failure}, wrap it with L{fail} and
    return it.

  - If the returned object is a L{types.CoroutineType}, wrap it with
    L{Deferred.fromCoroutine} and return it.

  - Otherwise, wrap it in L{succeed} and return it.

  - If an exception is raised, convert it to a L{Failure}, wrap it in
    L{fail}, and then return it.

@param f: The callable to invoke
@param args: The arguments to pass to C{f}
@param kwargs: The keyword arguments to pass to C{f}

@return: The result of the function call, wrapped in a L{Deferred} if
necessary.
captureVars)rg   re   r6   r\   debugtype_DEFERRED_SUBCLASSES
isinstancer   fromCoroutinerb   )ro   ri   rj   r]   returneds        rI   rp   rp      s    <9D#F# F|++	FG	$	$F|	f	&$ %%f--x  9  9G7889s   A3 3*B B Twisted      z*twisted.internet.defer.Deferred.addTimeout)replacementc                J    U R                  [        [        S5      5      5        g )NzCallback timed out)rd   r6   rP   )deferreds    rI   timeoutr      s    
 W\*>?@ArH   c                    U $ rm   r@   args    rI   passthrur          JrH   c                    U $ rm   r@   r   s    rI   	_failthrur     r   rH   c                ,    [        U 5      [        l        g)z
Enable or disable L{Deferred} debugging.

When debugging is on, the call stacks from creation and invocation are
recorded, and added to any L{AlreadyCalledError}s we raise.
N)boolr\   rw   )ons    rI   setDebuggingr     s     "XHNrH   c                 "    [         R                  $ )z5
Determine whether L{Deferred} debugging is enabled.
)r\   rw   r@   rH   rI   getDebuggingr     s     >>rH   c                r    [        U [        5      (       a!  U R                  [        5        [	        US5      eU $ )ab  
A default translation function that translates L{Failure}s that are
L{CancelledError}s to L{TimeoutError}s.

@param value: Anything
@param timeout: The timeout

@raise TimeoutError: If C{value} is a L{Failure} that is a L{CancelledError}.
@raise Exception: If C{value} is a L{Failure} that is not a L{CancelledError},
    it is re-raised.

@since: 16.5
r\   )rz   r6   traprL   rP   )valuer   s     rI   _cancelledToTimedOutErrorr     s/     %!!

>"7J//LrH   c                  4    \ rS rSrSr\" 5       r\" 5       rSrg)	_Sentineli-  a  
@cvar _NO_RESULT:
    The result used to represent the fact that there is no result.
    B{Never ever ever use this as an actual result for a Deferred}.
    You have been warned.
@cvar _CONTINUE:
    A marker left in L{Deferred.callback}s to indicate a Deferred chain.
    Always accompanied by a Deferred instance in the args tuple pointing at
    the Deferred which is chained to the Deferred which has this marker.
r@   N)	rB   rC   rD   rE   rF   object
_NO_RESULT	_CONTINUErG   r@   rH   rI   r   r   -  s    	 JIrH   r   ._CallbackKeywordArguments_NONE_KWARGS_SelfResultT_NextResultTc                  X    \ rS rSr% SrSrS\S'   SrS\S'   SrS\S'   SS	 jr	SS
 jr
Srg)	DebugInfoi_  z
Deferred debug helper.
NzOptional[Failure]
failResultzOptional[List[str]]creatorinvokerc                V   SnU R                   bF  US-  nUSR                  U R                   5      R                  5       R                  SS5      -  nUS-  nU R                  bF  US-  nUSR                  U R                  5      R                  5       R                  SS5      -  nUS-  nU$ )NrV   z C: Deferred was created:
 C:
z
 C:z I: First Invoker was:
 I:z
 I:)r   joinrstripreplacer   )selfinfos     rI   _getDebugTracebacksDebugInfo._getDebugTracebacksh  s    <<#44DBGGDLL)002::4IIDDLD<<#11DBGGDLL)002::4IIDDLDrH   c                    U R                   bO  [        R                  SSS9  U R                  5       nU(       a  SnOSn[        R	                  X R                   US9  gg)z
Print tracebacks and die.

If the *last* (and I do mean *last*) callback leaves me in an error
state, print a traceback (if said errback is a L{Failure}).
NzUnhandled error in Deferred:T)isErrorz(debug: {debugInfo})rV   )	debugInfo)r   rW   criticalr   rX   )r   r   formats      rI   __del__DebugInfo.__del__t  sU     ??& LL7LF002I/KK9KE 'rH   r@   returnstrr   None)rB   rC   rD   rE   rF   r   __annotations__r   r   r   r   rG   r@   rH   rI   r   r   _  s5     %)J!(#'G '#'G '
FrH   r   c                     \ rS rSr% SrSrSrSrS\S'   Sr	Sr
SrSrS\S	'    S5   S6S
 jjr\" \" SSSS5      5      S7S j5       rSS\S\4             S8S jjr\        S9S j5       r\        S:S j5       r\        S;S j5       r\        S<S j5       r\        S=S j5       r\        S>S j5       rS?S jr\        S@S j5       r\        SAS j5       r\        SBS j5       rSCS jr\        SDS j5       r\        SES j5       r\        SFS j5       r\        SGS j5       r\        SHS  j5       r\        SIS! j5       r\        SJS" j5       rS?S# jr S5       SKS$ jjrSLS% jrSMS& jrS5SNS' jjrSOS( jrSOS) jrSOS* jrSPS+ jrSQS, jrSOS- jr SRS. jr!\!r"SSS/ jr#\#r$STS0 jr%\&SUS1 j5       r'\&    SVS2 j5       r(SWS3 jr)S4r*g)Xr\   i  a  
This is a callback which will be put off until later.

Why do we want this? Well, in cases where a function in a threaded
program would block until it gets a result, for Twisted it should
not block. Instead, it should return a L{Deferred}.

This can be implemented for protocols that run over the network by
writing an asynchronous protocol for L{twisted.internet}. For methods
that come from outside packages that are not under our control, we use
threads (see for example L{twisted.enterprise.adbapi}).

For more information about Deferreds, see doc/core/howto/defer.html or
U{http://twistedmatrix.com/documents/current/core/howto/defer.html}

When creating a Deferred, you may provide a canceller function, which
will be called by d.cancel() to let you do any clean-up necessary if the
user decides not to wait for the deferred to complete.

@ivar called: A flag which is C{False} until either C{callback} or
    C{errback} is called and afterwards always C{True}.
@ivar paused: A counter of how many unmatched C{pause} calls have been made
    on this instance.
@ivar _suppressAlreadyCalled: A flag used by the cancellation mechanism
    which is C{True} if the Deferred has no canceller and has been
    cancelled, C{False} otherwise.  If C{True}, it can be expected that
    C{callback} or C{errback} will eventually be called and the result
    should be silently discarded.
@ivar _runningCallbacks: A flag which is C{True} while this instance is
    executing its callback chain, used to stop recursive execution of
    L{_runCallbacks}
@ivar _chainedTo: If this L{Deferred} is waiting for the result of another
    L{Deferred}, this is a reference to the other Deferred.  Otherwise,
    L{None}.
Fr   NzOptional[DebugInfo]
_debugInfoz'Optional[Deferred[Any]]'r_   c                    / U l         Xl        U R                  (       a7  [        5       U l        [
        R                  " 5       SS U R                  l        gg)a  
Initialize a L{Deferred}.

@param canceller: a callable used to stop the pending operation
    scheduled by this L{Deferred} when L{Deferred.cancel} is invoked.
    The canceller will be passed the deferred whose cancellation is
    requested (i.e., C{self}).

    If a canceller is not given, or does not invoke its argument's
    C{callback} or C{errback} method, L{Deferred.cancel} will
    invoke L{Deferred.errback} with a L{CancelledError}.

    Note that if a canceller is not given, C{callback} or
    C{errback} may still be invoked exactly once, even though
    defer.py will have already invoked C{errback}, as described
    above.  This allows clients of code which returns a L{Deferred}
    to cancel it without requiring the L{Deferred} instantiator to
    provide any specific implementation support for cancellation.
    New in 10.1.

@type canceller: a 1-argument callable which takes a L{Deferred}. The
    return result is ignored.
N)
_callbacks
_cancellerrw   r   r   	tracebackformat_stackr   r   	cancellers     rI   __init__Deferred.__init__  sA    4 13#::'kDO&/&<&<&>s&CDOO# rH   r}         c                    U R                   $ rm   )r   r   s    rI   	callbacksDeferred.callbacks  s    rH   r@   c                    Uc  [         nUc  SnUc  0 nUc  SnUc  0 nU R                  R                  XU4X%U445        U R                  (       a  U R	                  5         U $ )a  
Add a pair of callbacks (success and error) to this L{Deferred}.

These will be executed when the 'master' callback is run.

@note: The signature of this function was designed many years before
    PEP 612; ParamSpec provides no mechanism to annotate parameters
    like C{callbackArgs}; this is therefore inherently less type-safe
    than calling C{addCallback} and C{addErrback} separately.

@return: C{self}.
r@   )r   r   appendr^   _runCallbacks)r   callbackrd   callbackArgscallbackKeywordserrbackArgserrbackKeywordss          rI   addCallbacksDeferred.addCallbacks  s    L ?G L#!K" O 	)9:7	
 ;;  rH   c                    g rm   r@   r   r   ri   rj   s       rI   addCallbackDeferred.addCallback1       	rH   c                    g rm   r@   r   s       rI   r   r   :       	rH   c                    g rm   r@   r   s       rI   r   r   F  r   rH   c                    g rm   r@   r   s       rI   r   r   O  r   rH   c                    g rm   r@   r   s       rI   r   r   X  r   rH   c                    g rm   r@   r   s       rI   r   r   d  r   rH   c                    U R                   R                  XU4[        S0 445        U R                  (       a  U R	                  5         U $ )zF
Convenience method for adding just a callback.

See L{addCallbacks}.
r@   )r   r   r   r^   r   r   s       rI   r   r   m  s?     	 89b":MNO;; rH   c                    g rm   r@   r   rd   ri   rj   s       rI   
addErrbackDeferred.addErrback|  r   rH   c                    g rm   r@   r   s       rI   r   r     r   rH   c                    g rm   r@   r   s       rI   r   r     r   rH   c                    U R                   R                  [        S0 4XU445        U R                  (       a  U R	                  5         U $ )zF
Convenience method for adding just an errback.

See L{addCallbacks}.
r@   )r   r   r   r^   r   r   s       rI   r   r     s?     	2r 2WF4KLM;; rH   c                    g rm   r@   r   s       rI   addBothDeferred.addBoth  r   rH   c                    g rm   r@   r   s       rI   r   r     r   rH   c                    g rm   r@   r   s       rI   r   r          	rH   c                    g rm   r@   r   s       rI   r   r     r   rH   c                    g rm   r@   r   s       rI   r   r     r   rH   c                    g rm   r@   r   s       rI   r   r     r   rH   c                    g rm   r@   r   s       rI   r   r     r   rH   c                    XU4nU R                   R                  XD45        U R                  (       a  U R                  5         U $ )zj
Convenience method for adding a single callable as both a callback
and an errback.

See L{addCallbacks}.
)r   r   r^   r   )r   r   ri   rj   calls        rI   r   r     s:     '|,;; rH   c                   ^ ^^^^	 S/m	SU U	4S jjnUR                  TU5      m    SUU	U4S jjnSU4S jjnT R                  U5      nUR                  U5      $ )aA  
Time out this L{Deferred} by scheduling it to be cancelled after
C{timeout} seconds.

The timeout encompasses all the callbacks and errbacks added to this
L{defer.Deferred} before the call to L{addTimeout}, and none added
after the call.

If this L{Deferred} gets timed out, it errbacks with a L{TimeoutError},
unless a cancelable function was passed to its initialization or unless
a different C{onTimeoutCancel} callable is provided.

@param timeout: number of seconds to wait before timing out this
    L{Deferred}
@param clock: The object which will be used to schedule the timeout.
@param onTimeoutCancel: A callable which is called immediately after
    this L{Deferred} times out, and not if this L{Deferred} is
    otherwise cancelled before the timeout. It takes an arbitrary
    value, which is the value of this L{Deferred} at that exact point
    in time (probably a L{CancelledError} L{Failure}), and the
    C{timeout}.  The default callable (if C{None} is provided) will
    translate a L{CancelledError} L{Failure} into a L{TimeoutError}.

@return: C{self}.

@since: 16.5
Fc                 0   > STS'   T R                  5         g )NTr   cancel)r   timedOuts   rI   	timeItOut&Deferred.addTimeout.<locals>.timeItOut+  s    HQKKKMrH   c                L   > TS   (       a  T=(       d    [         nU" U T5      $ U $ )Nr   )r   )r]   toCallonTimeoutCancelr   r   s     rI   convertCancelled-Deferred.addTimeout.<locals>.convertCancelled1  s)    
 {(E,Efg..MrH   c                R   > TR                  5       (       a  TR                  5         U $ rm   )activer   )r]   delayedCalls    rI   cancelTimeout*Deferred.addTimeout.<locals>.cancelTimeout;  s#    !!##""$MrH   r   )r]   Union[_SelfResultT, Failure]r   z*Union[_SelfResultT, _NextResultT, Failure])r]   r8   r   r8   )	callLaterr   )
r   r   clockr   r   r   r  	convertedr  r   s
   `` `    @@rI   
addTimeoutDeferred.addTimeout  sq    N 7	 	 oogy9	0	7	 		 BFB
	   //rH   c                Z    Xl         U R                  UR                  UR                  5      $ )a  
Chain another L{Deferred} to this L{Deferred}.

This method adds callbacks to this L{Deferred} to call C{d}'s callback
or errback, as appropriate. It is merely a shorthand way of performing
the following::

    d1.addCallbacks(d2.callback, d2.errback)

When you chain a deferred C{d2} to another deferred C{d1} with
C{d1.chainDeferred(d2)}, you are making C{d2} participate in the
callback chain of C{d1}.
Thus any event that fires C{d1} will also fire C{d2}.
However, the converse is B{not} true; if C{d2} is fired, C{d1} will not
be affected.

Note that unlike the case where chaining is caused by a L{Deferred}
being returned from a callback, it is possible to cause the call
stack size limit to be exceeded by chaining many L{Deferred}s
together with C{chainDeferred}.

@return: C{self}.
)r_   r   r   rd   r   ra   s     rI   chainDeferredDeferred.chainDeferredI  s$    0   QYY77rH   c                &    U R                  U5        g)a  
Run all success callbacks that have been added to this L{Deferred}.

Each callback will have its result passed as the first argument to
the next; this way, the callbacks act as a 'processing chain'.  If
the success-callback returns a L{Failure} or raises an L{Exception},
processing will continue on the *error* callback chain.  If a
callback (or errback) returns another L{Deferred}, this L{Deferred}
will be chained to it (and further callbacks will not run until that
L{Deferred} has a result).

An instance of L{Deferred} may only have either L{callback} or
L{errback} called on it, and only once.

@param result: The object which will be passed to the first callback
    added to this L{Deferred} (via L{addCallback}), unless C{result} is
    a L{Failure}, in which case the behavior is the same as calling
    C{errback(result)}.

@raise AlreadyCalledError: If L{callback} or L{errback} has already been
    called on this L{Deferred}.
N)_startRunCallbacksr   r]   s     rI   r   Deferred.callbackd  s    . 	'rH   c                    Uc  [        U R                  S9nO [        U[         5      (       d  [        U5      nU R                  U5        g)a  
Run all error callbacks that have been added to this L{Deferred}.

Each callback will have its result passed as the first
argument to the next; this way, the callbacks act as a
'processing chain'. Also, if the error-callback returns a non-Failure
or doesn't raise an L{Exception}, processing will continue on the
*success*-callback chain.

If the argument that's passed to me is not a L{Failure} instance,
it will be embedded in one. If no argument is passed, a
L{Failure} instance will be created based on the current
traceback stack.

Passing a string as `fail' is deprecated, and will be punished with
a warning message.

An instance of L{Deferred} may only have either L{callback} or
L{errback} called on it, and only once.

@param fail: The L{Failure} object which will be passed to the first
    errback added to this L{Deferred} (via L{addErrback}).
    Alternatively, a L{Exception} instance from which a L{Failure} will
    be constructed (with no traceback) or L{None} to create a L{Failure}
    instance from the current exception state (with a traceback).

@raise AlreadyCalledError: If L{callback} or L{errback} has already been
    called on this L{Deferred}.
@raise NoCurrentExceptionError: If C{fail} is L{None} but there is
    no current exception state.
Nru   )r6   rw   rz   r  )r   re   s     rI   rd   Deferred.errback}  s<    @ <tzz2DD'**4=D%rH   c                .    U =R                   S-  sl         g)z@
Stop processing on a L{Deferred} until L{unpause}() is called.
r   N)pausedr   s    rI   pauseDeferred.pause  s     	qrH   c                    U =R                   S-  sl         U R                   (       a  gU R                  (       a  U R                  5         gg)z9
Process all callbacks made since L{pause}() was called.
r   N)r  r^   r   r   s    rI   unpauseDeferred.unpause  s4     	q;;;;  rH   c                J   U R                   (       dX  U R                  nU(       a	  U" U 5        OSU l        U R                   (       d#  U R                  [	        [        5       5      5        gg[        U R                  [        5      (       a  U R                  R                  5         gg)a  
Cancel this L{Deferred}.

If the L{Deferred} has not yet had its C{errback} or C{callback} method
invoked, call the canceller function provided to the constructor. If
that function does not invoke C{callback} or C{errback}, or if no
canceller function was provided, errback with L{CancelledError}.

If this L{Deferred} is waiting on another L{Deferred}, forward the
cancellation to the other L{Deferred}.
TN)
r^   r   _suppressAlreadyCalledrd   r6   rL   rz   r]   r\   r   r   s     rI   r   Deferred.cancel  sr     {{I$ /3+;; W^%567  X..KK  /rH   c                   U R                   (       at  U R                  (       a  SU l        g U R                  (       aD  U R                  c  [	        5       U l        SU R                  R                  5       -   n[        U5      e[        eU R                  (       aC  U R                  c  [	        5       U l        [        R                  " 5       S S U R                  l	        SU l         S U l
        Xl        U R                  5         g )NFr   T)r^   r  rw   r   r   r   r>   r   r   r   r   r]   r   )r   r]   extras      rI   r  Deferred._startRunCallbacks  s    ;;**.3+zz??*&/kDOtBBDD(//$$::&"++&/&<&<&>s&CDOO# rH   c                $    [         U 4[        4nX4$ )zD
Build a tuple of callback and errback with L{_Sentinel._CONTINUE}.
)r   r   )r   triples     rI   _continuationDeferred._continuation  s     dWl3rH   c                   U R                   (       a  gU /nU(       Ga  US   nUR                  (       a  gSnSUl        UR                  (       Ga  UR                  R	                  S5      n[        UR                  [        5      (       d	  US   u  pVnOUS   u  pVnU[        L ae  US   nUR                  Ul        SUl        UR                  b  SUR                  l
        U=R                  S-  sl        UR                  U5        SnGO- SUl          U" UR                  /UQ70 UD6Ul        UR                  UL a  [        US5        SUl          [        UR                  5      [        ;   a  UR                  n	[        U	S[         5      n
U
[         L d$  [        U
5      [        ;   d  U	R                  (       a@  UR#                  5         Xl        U	R                  R                  UR%                  5       5        O?SU	l        U	R                  b  SU	R                  l
        Xl        UR                  (       a  GM  U(       a  [        UR                  [        5      (       a8  UR                  c  [+        5       Ul	        UR                  UR                  l
        OUR                  b  SUR                  l
        UR	                  5         U(       a  GM  gg! SUl         f = f! [&         a    [        U R(                  S	9Ul         Nf = f)
a"  
Run the chain of callbacks once a result is available.

This consists of a simple loop over all of the callbacks, calling each
with the current result and making the current result equal to the
return value (or raised exception) of that call.

If L{_runningCallbacks} is true, this loop won't run at all, since
it is already running above us on the call stack.  If C{self.paused} is
true, the loop also won't run, because that's what it means to be
paused.

The loop will terminate before processing all of the callbacks if a
L{Deferred} without a result is encountered.

If a L{Deferred} I{with} a result is encountered, that result is taken
and the loop proceeds.

@note: The implementation is complicated slightly by the fact that
    chaining (associating two L{Deferred}s with each other such that one
    will wait for the result of the other, as happens when a Deferred is
    returned from a callback on another L{Deferred}) is supported
    iteratively rather than recursively, to avoid running out of stack
    frames when processing long chains.
Nr   Tr   r   Fz|Callback returned the Deferred it was attached to; this breaks the callback chain and will raise an exception in the future.r]   ru   )_runningCallbacksr  r_   r   poprz   r]   r6   r   r   r   r   r5   rx   ry   getattrr   r  r%  rg   rw   r   )r   chaincurrentfinisheditemr   ri   rj   chaineecurrentResultresultResults              rI   r   Deferred._runCallbacks  s   4 !! '+VBiG~~ H!%G$$$))--a0!'..'::-1!W*HF .2!W*HF y(
 15QG%,^^GN%)GN))58<**5NNa'NLL)  %H7:04G-: *2#NN*-1*5;* #>>W4- (!; 5:1 GNN+/CC@G (/}h
'S(J6#L15II,33 $MMO1>.
 *44;;G<Q<Q<ST! 48M0,77CFJ 8 8 C-9Ng $$$j 
 gnng66 ))1-6[*4;NNG&&1 ))58<**5 		g ez 5:1$ E &-%DGNEs*   
K 6K K 	KK "K?>K?c                    U R                   R                  n[        U S[        5      n[	        U 5      nU R
                  b  S[	        U R
                  5      S 3nOU[        L a  SnOSU< 3nSU SUS U S3$ )	z5
Return a string representation of this L{Deferred}.
r]   z waiting on Deferred at 0xxrV   z current result: <z at 0x>)	__class__rB   r*  r   idr_   )r   cnamer]   myIDs       rI   __str__Deferred.__str__  s     ''x4$x??&1"T__2Ea1HIFz!F(
3F5'Qxxq11rH   c              #    #     U R                   (       a  U v   M  [        U S[        5      nU[        L a  U v   M8  [        U[        5      (       a1  U R
                  c   eS U R
                  l        UR                  5         OU$ M  7f)Nr]   )r  r*  r   rz   r6   r   r   raiseExceptionr  s     rI   __iter__Deferred.__iter__  sv     {{
T8Z8F#
&'** 222-1*%%'% s   BBc                   ^ ^ UR                  5       mSU 4S jjnSU4S jjnSU4S jjnT R                  XC5        TR                  U5        T$ )a  
Adapt this L{Deferred} into a L{Future} which is bound to C{loop}.

@note: converting a L{Deferred} to an L{Future} consumes both
    its result and its errors, so this method implicitly converts
    C{self} into a L{Deferred} firing with L{None}, regardless of what
    its result previously would have been.

@since: Twisted 17.5.0

@param loop: The L{asyncio} event loop to bind the L{Future} to.

@return: A L{Future} which will fire when the L{Deferred} fires.
c                R   > U R                  5       (       a  TR                  5         g g rm   )	cancelledr   )futureAgainr   s    rI   checkCancel&Deferred.asFuture.<locals>.checkCancel  s     $$&& 'rH   c                h   > TR                  5       (       d  TR                  U R                  5        g g rm   )rC  set_exceptionr   )rX   futures    rI   	maybeFail$Deferred.asFuture.<locals>.maybeFail  s)    ##%%$$W]]3 &rH   c                T   > TR                  5       (       d  TR                  U 5        g g rm   )rC  
set_result)r]   rI  s    rI   maybeSucceed'Deferred.asFuture.<locals>.maybeSucceed  s%    ##%%!!&) &rH   )rD  'Future[_SelfResultT]'r   r   )rX   r6   r   r   r]   r   r   r   )create_futurer   add_done_callback)r   looprE  rJ  rN  rI  s   `    @rI   asFutureDeferred.asFuture  sE     ##%		4	* 	,2  -rH   c                   ^^^ SU4S jjn[        5       mSUU4S jjnU " U5      nUm    SUU4S jjnUR                  U5        TR                  U5        U$ )aS  
Adapt a L{Future} to a L{Deferred}.

@note: This creates a L{Deferred} from a L{Future}, I{not} from
    a C{coroutine}; in other words, you will need to call
    L{asyncio.ensure_future}, L{asyncio.loop.create_task} or create an
    L{asyncio.Task} yourself to get from a C{coroutine} to a
    L{Future} if what you have is an awaitable coroutine and
    not a L{Future}.  (The length of this list of techniques is
    exactly why we have left it to the caller!)

@since: Twisted 17.5.0

@param future: The L{Future} to adapt.

@return: A L{Deferred} which will fire when the L{Future} fires.
c                ~   >  U R                  5       nTR                  U5        g ! [         a    [        5       n N(f = frm   )r]   rg   r6   r   )r]   	extractedactuals     rI   adapt"Deferred.fromFuture.<locals>.adapt  s9    &4:MMO	 OOI& ! &#I	&s   % <<c                H   > TR                  5         U R                  T5        g rm   r   r   )reselfrI  futureCancels    rI   r   #Deferred.fromFuture.<locals>.cancel  s    MMOOOL)rH   c                *   > U TL a  [        5       mT$ U $ rm   )r\   )r]   rZ  r`  s    rI   uncancel%Deferred.fromFuture.<locals>.uncancel  s     %!MrH   )r]   zFuture[_SelfResultT]r   r   )r_  zDeferred[object]r   r   )r]   r   r   z+Union[_SelfResultT, Deferred[_SelfResultT]])r   r   rS  )clsrI  r[  r   r   rc  rZ  r`  s    `    @@rI   
fromFutureDeferred.fromFuture  sh    (	' x	* 	* 6{	 	8	 	 	"  'rH   c                    [        U5      (       d  [        R                  " U5      (       a  [        U5      $ [	        U< S35      e)a  
Schedule the execution of a coroutine that awaits on L{Deferred}s,
wrapping it in a L{Deferred} that will fire on success/failure of the
coroutine.

Coroutine functions return a coroutine object, similar to how
generators work. This function turns that coroutine into a Deferred,
meaning that it can be used in regular Twisted code. For example::

    import treq
    from twisted.internet.defer import Deferred
    from twisted.internet.task import react

    async def crawl(pages):
        results = {}
        for page in pages:
            results[page] = await treq.content(await treq.get(page))
        return results

    def main(reactor):
        pages = [
            "http://localhost:8080"
        ]
        d = Deferred.fromCoroutine(crawl(pages))
        d.addCallback(print)
        return d

    react(main)

@since: Twisted 21.2.0

@param coro: The coroutine object to schedule.

@raise ValueError: If C{coro} is not a coroutine or generator.
z is not a coroutine)r   inspectisgenerator_cancellableInlineCallbacksrS   )re  coros     rI   r{   Deferred.fromCoroutine  s>    \ t 3 3D 9 9.t44 D8+>!?@@rH   c                .    [         R                  U 5        g rm   )ry   r   )re  rj   s     rI   __init_subclass__Deferred.__init_subclass__7  s     	##C(rH   )r   r   r   r  r^   r]   rm   )r   z+Optional[Callable[['Deferred[Any]'], None]]r   r   )r   zList[_CallbackChain])r   zUnion[Callable[..., _NextResultT], Callable[..., Deferred[_NextResultT]], Callable[..., Failure], Callable[..., Union[_NextResultT, Deferred[_NextResultT], Failure]]]rd   zUnion[Callable[..., _NextResultT], Callable[..., Deferred[_NextResultT]], Callable[..., Failure], Callable[..., Union[_NextResultT, Deferred[_NextResultT], Failure]], None]r   zTuple[Any, ...]r   zMapping[str, Any]r   _CallbackOrderedArgumentsr   r   r   z'Deferred[_NextResultT]')r   z0Callable[Concatenate[_SelfResultT, _P], Failure]ri   _P.argsrj   	_P.kwargsr   Deferred[_NextResultT])r   zOCallable[Concatenate[_SelfResultT, _P], Union[Failure, Deferred[_NextResultT]]]ri   rr  rj   rs  r   rt  )r   zECallable[Concatenate[_SelfResultT, _P], Union[Failure, _NextResultT]]ri   rr  rj   rs  r   rt  )r   z?Callable[Concatenate[_SelfResultT, _P], Deferred[_NextResultT]]ri   rr  rj   rs  r   rt  )r   zTCallable[Concatenate[_SelfResultT, _P], Union[Deferred[_NextResultT], _NextResultT]]ri   rr  rj   rs  r   rt  )r   z5Callable[Concatenate[_SelfResultT, _P], _NextResultT]ri   rr  rj   rs  r   rt  )r   r   ri   r   rj   r   r   'Deferred[Any]')rd   z:Callable[Concatenate[Failure, _P], Deferred[_NextResultT]]ri   rr  rj   rs  r   -'Deferred[Union[_SelfResultT, _NextResultT]]')rd   z+Callable[Concatenate[Failure, _P], Failure]ri   rr  rj   rs  r   z'Deferred[Union[_SelfResultT]]')rd   z0Callable[Concatenate[Failure, _P], _NextResultT]ri   rr  rj   rs  r   rv  )rd   r   ri   r   rj   r   r   ru  )r   z@Callable[Concatenate[Union[_SelfResultT, Failure], _P], Failure]ri   rr  rj   rs  r   rt  )r   z_Callable[Concatenate[Union[_SelfResultT, Failure], _P], Union[Failure, Deferred[_NextResultT]]]ri   rr  rj   rs  r   rt  )r   zUCallable[Concatenate[Union[_SelfResultT, Failure], _P], Union[Failure, _NextResultT]]ri   rr  rj   rs  r   rt  )r   zOCallable[Concatenate[Union[_SelfResultT, Failure], _P], Deferred[_NextResultT]]ri   rr  rj   rs  r   rt  )r   zdCallable[Concatenate[Union[_SelfResultT, Failure], _P], Union[Deferred[_NextResultT], _NextResultT]]ri   rr  rj   rs  r   rt  )r   zECallable[Concatenate[Union[_SelfResultT, Failure], _P], _NextResultT]ri   rr  rj   rs  r   rt  )r   z!Callable[Concatenate[_T, _P], _T]ri   rr  rj   rs  r   Deferred[_SelfResultT])r   floatr  r-   r   zWOptional[Callable[[Union[_SelfResultT, Failure], float], Union[_NextResultT, Failure]]]r   rv  )ra   'Deferred[_SelfResultT]'r   z'Deferred[None]')r]   r  r   r   )re   'Optional[Union[Failure, BaseException]]r   r   r   rQ  )r   _CallbackChainr   )r   z5Generator[Deferred[_SelfResultT], None, _SelfResultT])rT  r   r   rP  )rI  rP  r   ry  )rl  zKUnion[Coroutine[Deferred[Any], Any, _T], Generator[Deferred[Any], Any, _T]]r   'Deferred[_T]')re  zType[Deferred[Any]]rj   r   )+rB   rC   rD   rE   rF   r^   r  r   r   r  r(  rw   r_   r   r4   r'   r   r   r   r&   r   r   r   r	  r  r   rd   r  r  r   r  r%  r   r;  __repr__r?  	__await__rU  classmethodrf  r{   ro  rG   r@   rH   rI   r\   r\     sn   "H FF&*J#*"
  E,0J)0 HLDDD	D@ 	2q!45 6. (*.:135A1A
A	
A* &+A, ,-A. //A0 31A2 
"3A^ B  	
 
   	
	 	 	 
 	 	 W  	
 
   Q  	
 
   	
	 	 	 
 	 	 G  	
 
   K  	
 
7  <  	
 
)  A  	
 
7  R  	
 
   	
	 	 	 
 	 	 

   
   

   
   	
	 	 	 
 	 	 W  	
 
   3  	
 
  8 E0E0 E0
	E0 
7E0N86(2%&N!!80 Xt2 H* I D / /b /A
/A 
/A /Ab)rH   r\   c                    [        U 5      [        ;   a  U $  [        R                  U 5      $ ! [         a    [	        U < S35      ef = f)a  
Schedule the execution of a coroutine that awaits/yields from L{Deferred}s,
wrapping it in a L{Deferred} that will fire on success/failure of the
coroutine. If a Deferred is passed to this function, it will be returned
directly (mimicking the L{asyncio.ensure_future} function).

See L{Deferred.fromCoroutine} for examples of coroutines.

@param coro: The coroutine object to schedule, or a L{Deferred}.
z! is not a coroutine or a Deferred)rx   ry   r\   r{   rS   )rl  s    rI   ensureDeferredr  @  sS    " Dz))	S))$//! 	S %x/P%QRR	Ss	   , Ac                  @    \ rS rSrSrS	S jrS
S jrS
S jrSS jrSr	g)
FirstErrori\  z
First error to occur in a L{DeferredList} if C{fireOnOneErrback} is set.

@ivar subFailure: The L{Failure} that occurred.
@ivar index: The index of the L{Deferred} in the L{DeferredList} where
    it happened.
c                H    [         R                  XU5        Xl        X l        g rm   )	Exceptionr   
subFailureindex)r   rX   r  s      rI   r   FirstError.__init__f  s    4%0!
rH   c                L    SU R                   U R                  R                  4-  $ )z
The I{repr} of L{FirstError} instances includes the repr of the
wrapped failure's exception and the index of the L{FirstError}.
zFirstError[#%d, %r])r  r  r   r   s    rI   r}  FirstError.__repr__k  s"    
 %

DOO4I4I'JJJrH   c                8    SU R                   U R                  4-  $ )z
The I{str} of L{FirstError} instances includes the I{str} of the
entire wrapped failure (including its traceback and exception) and
the index of the L{FirstError}.
zFirstError[#%d, %s]r  r  r   s    rI   r;  FirstError.__str__r  s     %

DOO'DDDrH   c                    [        U[        5      (       a8  [        U R                  U R                  4UR                  UR                  45      $ g)z
Comparison between L{FirstError} and other L{FirstError} instances
is defined as the comparison of the index and sub-failure of each
instance.  L{FirstError} instances don't compare equal to anything
that isn't a L{FirstError} instance.

@since: 8.2
r   )rz   r  r1   r  r  )r   others     rI   __cmp__FirstError.__cmp__z  s=     eZ((

DOO4u{{EDTDT6UVVrH   r  N)rX   r6   r  intr   r   r   )r  r   r   r  )
rB   rC   rD   rE   rF   r   r}  r;  r  rG   r@   rH   rI   r  r  \  s    
KErH   r  Fc                    g rm   r@   deferredListfireOnOneCallbackfireOnOneErrbackconsumeErrorss       rI   _DeferredListr    r   rH   c                    g rm   r@   r  s       rI   r  r    r   rH   c                    g rm   r@   r  s       rI   r  r    r   rH   c                  f    \ rS rSrSrSrSr   S	       S
S jjr        SS jrSS jr	Sr
g)DeferredListi  a  
L{DeferredList} is a tool for collecting the results of several Deferreds.

This tracks a list of L{Deferred}s for their results, and makes a single
callback when they have all completed.  By default, the ultimate result is a
list of (success, result) tuples, 'success' being a boolean.
L{DeferredList} exposes the same API that L{Deferred} does, so callbacks and
errbacks can be added to it in the same way.

L{DeferredList} is implemented by adding callbacks and errbacks to each
L{Deferred} in the list passed to it.  This means callbacks and errbacks
added to the Deferreds before they are passed to L{DeferredList} will change
the result that L{DeferredList} sees (i.e., L{DeferredList} is not special).
Callbacks and errbacks can also be added to the Deferreds after they are
passed to L{DeferredList} and L{DeferredList} may change the result that
they see.

See the documentation for the C{__init__} arguments for more information.

@ivar _deferredList: The L{list} of L{Deferred}s to track.
Fc                   [        U5      U l        S/[        U R                  5      -  U l         [        R                  U 5        [        U R                  5      S:X  a  U(       d  U R                  / 5        X l        X0l        X@l	        SU l
        SnU R                   H:  nUR                  U R                  U R                  U[        4U[        4S9  US-   nM<     g)a  
Initialize a DeferredList.

@param deferredList: The deferreds to track.
@param fireOnOneCallback: (keyword param) a flag indicating that this
    L{DeferredList} will fire when the first L{Deferred} in
    C{deferredList} fires with a non-failure result without waiting for
    any of the other Deferreds.  When this flag is set, the DeferredList
    will fire with a two-tuple: the first element is the result of the
    Deferred which fired; the second element is the index in
    C{deferredList} of that Deferred.
@param fireOnOneErrback: (keyword param) a flag indicating that this
    L{DeferredList} will fire when the first L{Deferred} in
    C{deferredList} fires with a failure result without waiting for any
    of the other Deferreds.  When this flag is set, if a Deferred in the
    list errbacks, the DeferredList will errback with a L{FirstError}
    failure wrapping the failure of that Deferred.
@param consumeErrors: (keyword param) a flag indicating that failures in
    any of the included L{Deferred}s should not be propagated to
    errbacks added to the individual L{Deferred}s after this
    L{DeferredList} is constructed.  After constructing the
    L{DeferredList}, any errors in the individual L{Deferred}s will be
    converted to a callback result of L{None}.  This is useful to
    prevent spurious 'Unhandled error in Deferred' messages from being
    logged.  This does not prevent C{fireOnOneErrback} from working.
Nr   r   r   r   )list_deferredListlen
resultListr\   r   r   r  r  r  finishedCountr   _cbDeferredSUCCESSFAILURE)r   r  r  r  r  r  r   s          rI   r   DeferredList.__init__  s    B ",/
 KORUS
 J
	 	$t!!"a'0AMM"
 "3 0***H!!    #W-"G,	 "  AIE +rH   c                X   X14U R                   U'   U =R                  S-  sl        U R                  (       d  U[        :X  a$  U R                  (       a  U R                  X45        OU[        :X  aL  U R                  (       a;  [        U[        5      (       d   eU R                  [        [        X5      5      5        OSU R                  [        U R                   5      :X  a0  U R                  [        [        [           U R                   5      5        U[        :X  a  U R                   (       a  gU$ )z9
(internal) Callback for when one of my deferreds fires.
r   N)r  r  r^   r  r  r   r  r  rz   r6   rd   r  r  r%   _DeferredListResultListTr   r  )r   r]   r  	succeededs       rI   r  DeferredList._cbDeferred  s     #,!4a{{G#(>(>vo.g%$*?*?!&'2222WZ%>?@##s4??';; d#;C#@$//RSD$6$6rH   c                    U R                   (       d%  U R                   H  n UR                  5         M     gg! [         a    [        R                  S5         M<  f = f)ar  
Cancel this L{DeferredList}.

If the L{DeferredList} hasn't fired yet, cancel every L{Deferred} in
the list.

If the L{DeferredList} has fired, including the case where the
C{fireOnOneCallback}/C{fireOnOneErrback} flag is set and the
L{DeferredList} fires because one L{Deferred} in the list fires with a
non-failure/failure result, do nothing in the C{cancel} method.
z-Exception raised from user supplied cancellerN)r^   r  r   rg   rW   rX   )r   r   s     rI   r   DeferredList.cancel.  sP     {{ ..QOO% /  % QKK OPQs   8AA)r  r  r  r  r  r  NFFF)r   Iterable[Deferred[_SelfResultT]]r  r   r  r   r  r   )r]   r   r  r  r  r   r   zOptional[_SelfResultT]r   )rB   rC   rD   rE   rF   r  r  r   r  r   rG   r@   rH   rI   r  r    s|    , 
 #(!&#D6D  D 	D
 DL"+.;?	4QrH   r  c               n     U  H  nUc   eUu  p4U(       a  M   e   U  Vs/ s H  oUS   PM	     sn$ s  snf )Nr   r@   )r  r  r]   successr   r4  s         rI   _parseDeferredListResultr  B  sI      F%%%#NG7N7 ! %%*QaD*%%%s   2c                >    [        U SUS9R                  [        5      $ )a  
Returns, via a L{Deferred}, a list with the results of the given
L{Deferred}s - in effect, a "join" of multiple deferred operations.

The returned L{Deferred} will fire when I{all} of the provided L{Deferred}s
have fired, or when any one of them has failed.

This method can be cancelled by calling the C{cancel} method of the
L{Deferred}, all the L{Deferred}s in the list will be cancelled.

This differs from L{DeferredList} in that you don't need to parse
the result for success/failure.

@param consumeErrors: (keyword param) a flag, defaulting to False,
    indicating that failures in any of the given L{Deferred}s should not be
    propagated to errbacks added to the individual L{Deferred}s after this
    L{gatherResults} invocation.  Any such errors in the individual
    L{Deferred}s will be converted to a callback result of L{None}.  This
    is useful to prevent spurious 'Unhandled error in Deferred' messages
    from being logged.  This parameter is available since 11.1.0.
T)r  r  )r  r   r  )r  r  s     rI   gatherResultsr  M  s#    0 t=k*+,rH   c                  0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )FailureGroupij  z!
More than one failure occurred.
c                6   > [         [        U ]  5         Xl        g rm   )superr  r   failures)r   r  r7  s     rI   r   FailureGroup.__init__o  s    lD*, rH   )r  )r  zSequence[Failure]r   r   )rB   rC   rD   rE   rF   r   rG   __classcell__)r7  s   @rI   r  r  j  s    ! !rH   r  c                   ^^^^	 Sm	SU4S jjn[        US9mSUUU	4S jjn/ mS	UUU4S jjn[        U 5      m[        U 5       H  u  pEUR                  X#U4U4S9  M     T$ )
a:  
Select the first available result from the sequence of Deferreds and
cancel the rest.

@return: A cancellable L{Deferred} that fires with the index and output of
    the element of C{ds} to have a success result first, or that fires
    with L{FailureGroup} holding a list of their failures if they all
    fail.
Nc                8   > T H  nUR                  5         M     g rm   r   )r]   ra   	to_cancels     rI   r   race.<locals>.cancel  s    
 AHHJ rH   r   c                |   > Tc8  TU   mT H  nUTLd  M
  UR                  5         M     TR                  X45        g g rm   r^  )this_output
this_indexra   final_resultr  winners      rI   r  race.<locals>.succeeded  sH     >z*F F?HHJ 
 !!:";< rH   c                   > TR                  X45        [        T5      [        T5      :X  aA  TR                  5         T VVs/ s H  u  p#UPM	     nnnTR                  [	        U5      5        g g s  snnf rm   )r   r  sortrd   r  )rX   r  ignoredro   r  failure_stater  r  s        rI   failedrace.<locals>.failed  sd    j23}Y/ .;<mlwmH<  h!78	 0 =s   A.r  )r]   Deferred[_T]r   r   )r  r8   r  r  r   r   )rX   r6   r  r  r   r   )r\   r  	enumerater   )
dsr   r  r  r  ra   r  r  r  r  s
         @@@@rI   racer  t  sq     &*F .6-GL= =0 M9 9 RIbM 	
yxeXV	 " rH   Tc                      \ rS rSrSS jrSrg)_DefGen_Returni  c                    Xl         g rm   r   )r   r   s     rI   r   _DefGen_Return.__init__  s    
rH   r  N)r   r   r   r   )rB   rC   rD   rE   r   rG   r@   rH   rI   r  r    s    rH   r     r:   zstandard return statementc                    [        U 5      e)a  
Return val from a L{inlineCallbacks} generator.

Note: this is currently implemented by raising an exception
derived from L{BaseException}.  You might want to change any
'except:' clauses to an 'except Exception:' clause so as not to
catch this exception.

Also: while this function currently will work when called from
within arbitrary functions called from within the generator, do
not rely upon this behavior.
)r  )vals    rI   returnValuer    s    " 
rH   )auto_attribsc                  2    \ rS rSr% SrS\S'   SrS\S'   Srg)	_CancellationStatusi  a  
Cancellation status of an L{inlineCallbacks} invocation.

@ivar deferred: the L{Deferred} to callback or errback when the generator
    invocation has finished.
@ivar waitingOn: the L{Deferred} being waited upon (which
    L{_inlineCallbacks} must fill out before returning)
rw  r   Nz Optional[Deferred[_SelfResultT]]	waitingOnr@   )rB   rC   rD   rE   rF   r   r  rG   r@   rH   rI   r  r    s     %$26I/6rH   r  c                D    US   (       a
  SUS'   XS'   g[        XX45        g)a  
Helper for L{_inlineCallbacks} to handle a nested L{Deferred} firing.

@param r: The result of the L{Deferred}
@param waiting: Whether the L{_inlineCallbacks} was waiting, and the result.
@param gen: a generator object returned by calling a function or method
    decorated with C{@}L{inlineCallbacks}
@param status: a L{_CancellationStatus} tracking the current status of C{gen}
@param context: the contextvars context to run `gen` in
r   Fr   N)_inlineCallbacks)rwaitinggenstatuscontexts        rI   _gotResultInlineCallbacksr    s%    ( qz

1rH   c                   SS/nSnSn  [        U [        5      nU(       a+  UR                  [        [        U 5      R                  U5      n OUR                  UR
                  U 5      n  U(       a  UR,                  R1                  U5        g[3        U 5      [4        ;   nU(       d8  [7        U 5      (       d  [8        R:                  " U 5      (       a  [=        U 5      n SnU(       a<  U R?                  [@        XAX#5        US
   (       a  SUS
'   Xl!        gUS   n SUS
'   SUS'   GM  ! [         a  nSn[        USS5      n SnANSnAf[         Ga  n[        5       n	U	c   eU	S   n
U
c   eU
R                  nUc   e[        (       a  UR                  nUc   eW(       a  UR                  nUc   eUR                  c   eUR                  R                  c   eUR                  R                  R                  (       Ga8  UnUc   eUR                  c   eUR                  R                  c   eUR                  R                  R                  (       a8  UR                  nUc   eUR                  R                  R                  (       a  M8  UR                  R                  R                  nUR                  nUR                  c   eUR                  c   e[         R"                  " SUR                  R                  R$                  < SUR                  R                  R$                  < S	3[&        UU5        SnUR(                  n SnAGNSnAf[*         a    UR,                  R/                  5          gf = f)a:  
Carry out the work of L{inlineCallbacks}.

Iterate the generator produced by an C{@}L{inlineCallbacks}-decorated
function, C{gen}, C{send()}ing it the results of each value C{yield}ed by
that generator, until a L{Deferred} is yielded, at which point a callback
is added to that L{Deferred} to call this function again.

@param result: The last result seen by this generator.  Note that this is
    never a L{Deferred} - by the time this function is invoked, the
    L{Deferred} has been called back and this will be a particular result
    at a point in its callback chain.

@param gen: a generator object returned by calling a function or method
    decorated with C{@}L{inlineCallbacks}

@param status: a L{_CancellationStatus} tracking the current status of C{gen}

@param context: the contextvars context to run `gen` in
TNFr   r      zreturnValue() in z	 causing zX to exit: returnValue should only be invoked by functions decorated with inlineCallbacksr   )"rz   r6   runr%   throwExceptionIntoGeneratorsendStopIterationr*  r  r   tb_next_oldPypyStacktb_framef_codeco_filename	tb_linenowarningswarn_explicitco_nameDeprecationWarningr   rg   r   rd   r   rx   ry   r   ri  rj  rk  r   r  r  )r]   r  r  r  r  stopIterationcallbackValue	isFailureeexcInfor   appCodeTraceultimateTracefilenamelineno
isDeferreds                   rI   r  r    sD   H GMM
e	"673I &)EEs !SXXv6|  OO$$]3&\%99
 {622g6I6I&6Q6Q08FJ NN4gFTqz #
#) QZF GAJGAJS   	6 M#Aw5M R	$ jG&&&
I((($,,L+++}  ,33#///  ,33#///  ''333''//;;;##++333 !-$000$,,888 %,,44@@@#++33;;$1$9$9M(444 $++33;;; )1188DD&00$--999#,,888&&
 &..55==$--44<< ' !MGGM 	OO##%	s8   AD$ D$ $
M2.EM2D6MB:M'M21M2c                    / U R                   sU l         nU R                  [        U5      n U R                   R                  U5        U R	                  [        5       5        g)z
Helper for L{_cancellableInlineCallbacks} to add
L{_handleCancelInlineCallbacks} as the first errback.

@param it: The L{Deferred} to add the errback to.
@param status: a L{_CancellationStatus} tracking the current status of C{gen}
N)r   r   _handleCancelInlineCallbacksextendrd   &_InternalInlineCallbacksCancelledError)itr  tmps      rI   _addCancelCallbackToDeferredr    sI     R]]BM3	3V	<BMMJJ578rH   c                  ^ U R                  [        5        [        U4S j5      Tl        TR                  nUc   eUR                  5         TR                  $ )ai  
Propagate the cancellation of an C{@}L{inlineCallbacks} to the
L{Deferred} it is waiting on.

@param result: An L{_InternalInlineCallbacksCancelledError} from
    C{cancel()}.
@param status: a L{_CancellationStatus} tracking the current status of C{gen}
@return: A new L{Deferred} that the C{@}L{inlineCallbacks} generator
    can callback or errback through.
c                   > [        U T5      $ rm   r  ra   r  s    rI   <lambda>._handleCancelInlineCallbacks.<locals>.<lambda>  s    )Ea)PrH   )r   r  r\   r   r  r   )r]   r  awaiteds    ` rI   r  r    sL     KK67PQFO GNN??rH   c                h   ^ [        U4S j5      n[        U5      m[        SU T[        5       5        U$ )z
Make an C{@}L{inlineCallbacks} cancellable.

@param gen: a generator object returned by calling a function or method
    decorated with C{@}L{inlineCallbacks}

@return: L{Deferred} for the C{@}L{inlineCallbacks} that is cancellable.
c                   > [        U T5      $ rm   r
  r  s    rI   r  -_cancellableInlineCallbacks.<locals>.<lambda>  s    0LQPV0WrH   N)r\   r  r  _copy_context)r  r   r  s     @rI   rk  rk    s/     &&WXH *FT38OrH   c                      \ rS rSrSrSrg)r  i  z
A unique exception used only in L{_cancellableInlineCallbacks} to verify
that an L{inlineCallbacks} is being cancelled as expected.
r@   NrA   r@   rH   rI   r  r    rJ   rH   r  c                4   ^  [        T 5      SU 4S jj5       nU$ )aT
  
L{inlineCallbacks} helps you write L{Deferred}-using code that looks like a
regular sequential function. For example::

    @inlineCallbacks
    def thingummy():
        thing = yield makeSomeRequestResultingInDeferred()
        print(thing)  # the result! hoorj!

When you call anything that results in a L{Deferred}, you can simply yield it;
your generator will automatically be resumed when the Deferred's result is
available. The generator will be sent the result of the L{Deferred} with the
'send' method on generators, or if the result was a failure, 'throw'.

Things that are not L{Deferred}s may also be yielded, and your generator
will be resumed with the same object sent back. This means C{yield}
performs an operation roughly equivalent to L{maybeDeferred}.

Your inlineCallbacks-enabled generator will return a L{Deferred} object, which
will result in the return value of the generator (or will fail with a
failure object if your generator raises an unhandled exception). Inside
the generator simply use C{return result} to return a value.

Be aware that generator must not return a L{Deferred}.
If you believe the thing you'd like to return could be a L{Deferred}, do
this::

    result = yield result
    return result

The L{Deferred} returned from your deferred generator may errback if your
generator raised an exception::

    @inlineCallbacks
    def thingummy():
        thing = yield makeSomeRequestResultingInDeferred()
        if thing == 'I love Twisted':
            # will become the result of the Deferred
            return 'TWISTED IS GREAT!'
        else:
            # will trigger an errback
            raise Exception('DESTROY ALL LIFE')

You can cancel the L{Deferred} returned from your L{inlineCallbacks}
generator before it is fired by your generator completing (either by
reaching its end, a C{return} statement, or by calling L{returnValue}).
A C{CancelledError} will be raised from the C{yield}ed L{Deferred} that
has been cancelled if that C{Deferred} does not otherwise suppress it.

C{inlineCallbacks} behaves very similarly to coroutines. Since Twisted 24.7.0
it is possible to rewrite functions using C{inlineCallbacks} to C{async def}
in piecewise manner and be mostly compatible to existing code.

The rewrite process is simply replacing C{inlineCallbacks} decorator with
C{async def} and all C{yield} occurrences in the function body with C{await}.
The function will no longer return a C{Deferred} but a awaitable coroutine.
This return value will obviously not have C{Deferred} methods such as
C{addCallback}, but it will be possible to C{yield} it in other code based
on C{inlineCallbacks}.
c                    >  T" U 0 UD6n[        U[        5      (       d  [        ST< SU< 35      e[	        U5      $ ! [          a    [        ST< S35      ef = f)NzinlineCallbacks requires zP to produce a generator; insteadcaught returnValue being used in a non-generatorz% to produce a generator; instead got )r  	TypeErrorrz   r   rk  )ri   rj   r  ro   s      rI   unwindGenerator(inlineCallbacks.<locals>.unwindGeneratorJ  sq    	T$V$C #}--$%s,  +3//  	FGJ 	s	   > A)ri   rr  rj   rs  r   r  r   )ro   r  s   ` rI   inlineCallbacksr  
  s$    @ 1X0 0 rH   c                  
   \ rS rSrSS jrSS jr\          SS j5       r\          SS j5       r\          SS j5       r          SS jrSS jr        SS	 jr	\
SS
 j5       r\
SS j5       rSrg)_ConcurrencyPrimitivei`  c                    / U l         g rm   r  r   s    rI   r   _ConcurrencyPrimitive.__init__a  s	    -/rH   c                &    U R                  5         U$ rm   )release)r   r  s     rI   _releaseAndReturn'_ConcurrencyPrimitive._releaseAndReturnd  s    rH   c                   g rm   r@   r   ro   ri   rj   s       rI   r  _ConcurrencyPrimitive.runh       	rH   c                   g rm   r@   r$  s       rI   r  r%  r  r&  rH   c                   g rm   r@   r$  s       rI   r  r%  |  s     	rH   c               ^   ^ ^^^ SUUUU 4S jjnT R                  5       R                  U5      $ )a  
Acquire, run, release.

This method takes a callable as its first argument and any
number of other positional and keyword arguments.  When the
lock or semaphore is acquired, the callable will be invoked
with those arguments.

The callable may return a L{Deferred}; if it does, the lock or
semaphore won't be released until that L{Deferred} fires.

@return: L{Deferred} of function result.
c                T   > [        T/TQ70 TD6R                  TR                  5      $ rm   )rp   r   r!  )ignoredResultri   ro   rj   r   s    rI   rk   *_ConcurrencyPrimitive.run.<locals>.execute  s0     !4T4V4<<&& rH   )r+  r   r   r  )acquirer   )r   ro   ri   rj   rk   s   ```` rI   r  r%    s&    *	 	 ||~))'22rH   c                "    U R                  5       $ )z4
We can be used as an asynchronous context manager.
)r-  r   s    rI   
__aenter__ _ConcurrencyPrimitive.__aenter__  s     ||~rH   c                8    U R                  5         [        S5      $ )NF)r   rb   )r   _ConcurrencyPrimitive__exc_type _ConcurrencyPrimitive__exc_value _ConcurrencyPrimitive__tracebacks       rI   	__aexit___ConcurrencyPrimitive.__aexit__  s     	 u~rH   c                    g rm   r@   r   s    rI   r-  _ConcurrencyPrimitive.acquire      rH   c                    g rm   r@   r   s    rI   r   _ConcurrencyPrimitive.release  r9  rH   r  Nr   r+   r   r   )r  r8   r   r8   )
ro   Callable[_P, Deferred[_T]]r   r+   ri   rr  rj   rs  r   r  )
ro   /Callable[_P, Coroutine[Deferred[Any], Any, _T]]r   r+   ri   rr  rj   rs  r   r  )
ro   Callable[_P, _T]r   r+   ri   rr  rj   rs  r   r  )
ro   HCallable[_P, Union[Deferred[_T], Coroutine[Deferred[Any], Any, _T], _T]]r   r+   ri   rr  rj   rs  r   r  r   r+   r   Deferred[Self])r2  zOptional[Type[BaseException]]r3  zOptional[BaseException]r4  zOptional[TracebackType]r   zDeferred[Literal[False]]r   )rB   rC   rD   rE   r   r!  r&   r  r/  r5  r   r-  r   rG   r@   rH   rI   r  r  `  s^   0  & 	
  
   ; 	
  
  *3:FO	 
3 T33 	3
 3 
3<	1	 -	 -		
 
"	    rH   r  c                  :    \ rS rSrSrSrS	S jrS
S jrSS jrSr	g)DeferredLocki  z
A lock for event driven systems.

@ivar locked: C{True} when this Lock has been acquired, false at all other
    times.  Do not change this value, but it is useful to examine for the
    equivalent of a "non-blocking" acquisition.
Fc                :    U R                   R                  U5        gax  
Remove a deferred d from our waiting list, as the deferred has been
canceled.

Note: We do not need to wrap this in a try/except to catch d not
being in self.waiting because this canceller will not be called if
d has fired. release() pops a deferred out of self.waiting and
calls it, so the canceller will no longer be called.

@param d: The deferred that has been canceled.
Nr  remover  s     rI   _cancelAcquireDeferredLock._cancelAcquire       	ArH   c                    [        U R                  S9nU R                  (       a  U R                  R	                  U5        U$ SU l        UR                  U 5        U$ )a  
Attempt to acquire the lock.  Returns a L{Deferred} that fires on
lock acquisition with the L{DeferredLock} as the value.  If the lock
is locked, then the Deferred is placed at the end of a waiting list.

@return: a L{Deferred} which fires on lock acquisition.
@rtype: a L{Deferred}
r  T)r\   rI  lockedr  r   r   r  s     rI   r-  DeferredLock.acquire  sN     %t/B/BC;;LL"  DKJJtrH   c                    U R                   (       d   S5       eSU l         U R                  (       a4  SU l         U R                  R                  S5      nUR                  U 5        gg)z
Release the lock.  If there is a waiting list, then the first
L{Deferred} in that waiting list will be called back.

Should be called by whomever did the L{acquire}() when the shared
resource is free.
z!Tried to release an unlocked lockFTr   N)rM  r  r)  r   r  s     rI   r   DeferredLock.release  sP     {{???{<<DK  #AJJt	 rH   )rM  Nr   r+   ra   rB  r   r   rA  r<  )
rB   rC   rD   rE   rF   rM  rI  r-  r   rG   r@   rH   rI   rD  rD    s     F"rH   rD  c                  @    \ rS rSrSrS	S jrS
S jrSS jrSS jrSr	g)DeferredSemaphorei  ao  
A semaphore for event driven systems.

If you are looking into this as a means of limiting parallelism, you might
find L{twisted.internet.task.Cooperator} more useful.

@ivar limit: At most this many users may acquire this semaphore at
    once.
@ivar tokens: The difference between C{limit} and the number of users
    which have currently acquired this semaphore.
c                h    [         R                  U 5        US:  a  [        S5      eXl        Xl        g)zM
@param tokens: initial value of L{tokens} and L{limit}
@type tokens: L{int}
r   z&DeferredSemaphore requires tokens >= 1N)r  r   
ValueErrortokenslimit)r   rV  s     rI   r   DeferredSemaphore.__init__	  s/    
 	&&t,A:EFF
rH   c                :    U R                   R                  U5        grF  rG  r  s     rI   rI   DeferredSemaphore._cancelAcquire	  rK  rH   c                    U R                   S:  d   S5       e[        U R                  S9nU R                   (       d  U R                  R	                  U5        U$ U R                   S-
  U l         UR                  U 5        U$ )zY
Attempt to acquire the token.

@return: a L{Deferred} which fires on token acquisition.
r   z9Internal inconsistency??  tokens should never be negativer  r   )rV  r\   rI  r  r   r   r  s     rI   r-  DeferredSemaphore.acquire	  st     KK1	GF	G$t/B/BC{{LL"  ++/DKJJtrH   c                   U R                   U R                  :  d   S5       eU R                   S-   U l         U R                  (       aA  U R                   S-
  U l         U R                  R                  S5      nUR	                  U 5        gg)zh
Release the token.

Should be called by whoever did the L{acquire}() when the shared
resource is free.
z4Someone released me too many times: too many tokens!r   r   N)rV  rW  r  r)  r   r  s     rI   r   DeferredSemaphore.release,	  sp     KK$**$	BA	B$kkAo<<++/DK  #AJJt	 rH   )rW  rV  N)rV  r  r   r   rQ  rA  r<  )
rB   rC   rD   rE   rF   r   rI  r-  r   rG   r@   rH   rI   rS  rS    s    
	"rH   rS  c                      \ rS rSrSrg)QueueOverflowi>	  r@   NrB   rC   rD   rE   rG   r@   rH   rI   r`  r`  >	      rH   r`  c                      \ rS rSrSrg)QueueUnderflowiB	  r@   Nra  r@   rH   rI   rd  rd  B	  rb  rH   rd  c                  P    \ rS rSrSr S	     S
S jjrSS jrSS jrSS jrSr	g)DeferredQueueiF	  a  
An event driven queue.

Objects may be added as usual to this queue.  When an attempt is
made to retrieve an object when the queue is empty, a L{Deferred} is
returned which will fire when an object becomes available.

@ivar size: The maximum number of objects to allow into the queue
    at a time.  When an attempt to add a new object would exceed this
    limit, L{QueueOverflow} is raised synchronously.  L{None} for no limit.
@ivar backlog: The maximum number of L{Deferred} gets to allow at
    one time.  When an attempt is made to get an object which would
    exceed this limit, L{QueueUnderflow} is raised synchronously.  L{None}
    for no limit.
Nc                8    / U l         / U l        Xl        X l        g rm   )r  pendingsizebacklog)r   ri  rj  s      rI   r   DeferredQueue.__init__W	  s     ,.!#	rH   c                :    U R                   R                  U5        g)at  
Remove a deferred d from our waiting list, as the deferred has been
canceled.

Note: We do not need to wrap this in a try/except to catch d not
being in self.waiting because this canceller will not be called if
d has fired. put() pops a deferred out of self.waiting and calls
it, so the canceller will no longer be called.

@param d: The deferred that has been canceled.
NrG  r  s     rI   
_cancelGetDeferredQueue._cancelGet_	  rK  rH   c                &   U R                   (       a+  U R                   R                  S5      R                  U5        gU R                  b#  [	        U R
                  5      U R                  :  a  U R
                  R                  U5        g[        5       e)zY
Add an object to this queue.

@raise QueueOverflow: Too many objects are in this queue.
r   N)r  r)  r   ri  r  rh  r   r`  )r   objs     rI   putDeferredQueue.putm	  s`     <<LLQ((-YY#dll"3dii"?LL$/!rH   c                @   U R                   (       a$  [        U R                   R                  S5      5      $ U R                  b#  [	        U R
                  5      U R                  :  a0  [        U R                  S9nU R
                  R                  U5        U$ [        5       e)a  
Attempt to retrieve and remove an object from the queue.

@return: a L{Deferred} which fires with the next object available in
the queue.

@raise QueueUnderflow: Too many (more than C{backlog})
L{Deferred}s are already waiting for an object from this queue.
r   r  )
rh  rb   r)  rj  r  r  r\   rm  r   rd  r  s     rI   getDeferredQueue.getz	  sq     <<4<<++A.//\\!S%6%E&AALL"H ""rH   )rj  rh  ri  r  )NN)ri  Optional[int]rj  rv  r   r   )ra   r  r   r   )rp  r8   r   r   )r   r  )
rB   rC   rD   rE   rF   r   rm  rq  rt  rG   r@   rH   rI   rf  rf  F	  s:    " DH!3@	"#rH   rf  c                      \ rS rSrSrSrg)AlreadyTryingToLockErrori	  zo
Raised when L{DeferredFilesystemLock.deferUntilLocked} is called twice on a
single L{DeferredFilesystemLock}.
r@   NrA   r@   rH   rI   rx  rx  	  rJ   rH   rx  c                  V    \ rS rSr% SrSrSrS\S'   SrS\S'   SSS jjr	SSS	 jjr
S
rg)DeferredFilesystemLocki	  a>  
A L{FilesystemLock} that allows for a L{Deferred} to be fired when the lock is
acquired.

@ivar _scheduler: The object in charge of scheduling retries. In this
    implementation this is parameterized for testing.
@ivar _interval: The retry interval for an L{IReactorTime} based scheduler.
@ivar _tryLockCall: An L{IDelayedCall} based on C{_interval} that will manage
    the next retry for acquiring the lock.
@ivar _timeoutCall: An L{IDelayedCall} based on C{deferUntilLocked}'s timeout
    argument.  This is in charge of timing out our attempt to acquire the
    lock.
r   NzOptional[IDelayedCall]_tryLockCall_timeoutCallc                    [         R                  R                  X5        Uc  SSKJn  [        [        U5      nX l        g)zi
@param name: The name of the lock to acquire
@param scheduler: An object which provides L{IReactorTime}
Nr   )reactor)r/   FilesystemLockr   twisted.internetr~  r%   r-   
_scheduler)r   name	schedulerr~  s       rI   r   DeferredFilesystemLock.__init__	  s2    
 	((40\73I#rH   c                   ^ ^^^^ T R                   b  [        [        S5      5      $ SUU 4S jjm[        U4S j5      mSUUUU U4S jjmT" 5         T$ )a  
Wait until we acquire this lock.  This method is not safe for
concurrent use.

@param timeout: the number of seconds after which to time out if the
    lock has not been acquired.

@return: a L{Deferred} which will callback when the lock is acquired, or
    errback with a L{TimeoutError} after timing out or an
    L{AlreadyTryingToLockError} if the L{deferUntilLocked} has already
    been called and not successfully locked the file.
z/deferUntilLocked isn't safe for concurrent use.c                p  > TR                   c   eTR                   R                  5         STl         TR                  b@  TR                  R                  5       (       a!  TR                  R                  5         STl        TR	                  5       (       a  TR                  S5        gTR                  U 5        g)z
Cancel a L{DeferredFilesystemLock.deferUntilLocked} call.

@type reason: L{Failure}
@param reason: The reason why the call is cancelled.
N)r{  r   r|  r  lockr   rd   )reasonra   r   s    rI   _cancelLock<DeferredFilesystemLock.deferUntilLocked.<locals>._cancelLock	  s     $$000$$& $D  ,1B1B1I1I1K1K!!((*$(!yy{{

4 		&!rH   c                $   > T" [        5       5      $ rm   )rL   )r   r  s    rI   r  9DeferredFilesystemLock.deferUntilLocked.<locals>.<lambda>	  s    k.BR6SrH   c                   > TR                  5       (       aG  TR                  b!  TR                  R                  5         S Tl        S Tl        TR	                  S 5        g TbR  TR                  cE  [        [        STR                  T4-  5      5      n TR                  R                  TTU 5      Tl        TR                  R                  TR                  T5      Tl        g )Nz&Timed out acquiring lock: %s after %fs)r  r|  r   r{  r   r6   rP   r  r  r  	_interval)r  r  _tryLockra   r   r   s    rI   r  9DeferredFilesystemLock.deferUntilLocked.<locals>._tryLock	  s    yy{{$$0%%,,.(,D%$(!

4 &4+<+<+D$$D#yy'23F )-(A(Af)D% %)OO$=$=dnnh$W!rH   )r  zUnion[Failure, Exception]r   r   r   )r{  re   rx  r\   )r   r   r  r  ra   s   ``@@@rI   deferUntilLocked'DeferredFilesystemLock.deferUntilLocked	  sX     ((E 	" 	"& %%ST	X 	X. 	
rH   )r  r|  r{  rm   )r  r   r  zOptional[IReactorTime]r   r   )r   zOptional[float]r   zDeferred[None])rB   rC   rD   rE   rF   r  r{  r   r|  r   r  rG   r@   rH   rI   rz  rz  	  s5     I+/L(/+/L(/$B BrH   rz  )r\   r  rb   re   r  r  r>   rP   r  rp   r  r  r  rD  rS  rf  rz  rx  rL   )rY   r6   r   r6   )r]   r8   r   r|  rm   )r]   rz  r   ru  )rh   r?  ri   rr  rj   rs  r   r|  )ro   r=  ri   rr  rj   rs  r   r|  )ro   r>  ri   rr  rj   rs  r   r|  )ro   r?  ri   rr  rj   rs  r   r|  )ro   r@  ri   rr  rj   rs  r   r|  )r   z'Deferred[object]'r   r   )r   r8   r   r8   )r   r6   r   r6   )r   r   r   r   )r   r   )r   r8   r   rx  r   r8   )rl  zYUnion[Coroutine[Deferred[Any], Any, _T], Generator[Deferred[Any], Any, _T], Deferred[_T]]r   r  )FF)
r  r  r  zLiteral[True]r  r   r  r   r   z2Deferred[_DeferredListSingleResultT[_SelfResultT]]r  )
r  r  r  zLiteral[False]r  r   r  r   r   z0Deferred[_DeferredListResultListT[_SelfResultT]])
r  r  r  r   r  r   r  r   r   zkUnion[Deferred[_DeferredListSingleResultT[_SelfResultT]], Deferred[_DeferredListResultListT[_SelfResultT]]])F)r  z"List[_DeferredListResultItemT[_T]]r  r   r   zList[_T])r  zIterable[Deferred[_T]]r  r   r   zDeferred[List[_T]])r  zSequence[Deferred[_T]]r   zDeferred[tuple[int, _T]])r  r   r   r   )r  r   r  z	List[Any]r  KUnion[Generator[Deferred[Any], Any, _T], Coroutine[Deferred[Any], Any, _T]]r  _CancellationStatus[_T]r  _Contextr   r   )
r]   r   r  r  r  r  r  r  r   r   )r  r  r  r  r   r   )r]   r6   r  r  r   r  )r  zQUnion[Generator[Deferred[Any], object, _T], Coroutine[Deferred[Any], object, _T]]r   r  )ro   z/Callable[_P, Generator[Deferred[Any], Any, _T]]r   r=  )rF   
__future__r   ri  r   r  abcr   r   asyncior   r   r   contextvarsr	   r  r
   r  enumr   	functoolsr   sysr   r   typesr   r   r   r   typingr   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   attrincrementalr'   typing_extensionsr(   r)   r*   r+   twisted.internet.interfacesr,   r-   twisted.loggerr.   twisted.pythonr/   twisted.python.compatr0   r1   r2   twisted.python.deprecater3   r4   r5   twisted.python.failurer6   r7   rW   r8   r9   versionr  r  r>   rL   rP   r  rS   rZ   rb   re   rk   rp   r   r   r   r   r   r   r   r   r   r   DeferredCallbackDeferredErrbackrq  r   r   r{  r   r   r   r   r   r\   ry   r  r  r  _DeferredListSingleResultTr   _DeferredListResultItemTr  r  r  r  r  r  r  r  r  rg   r  r  sr  r  r  r  r  rk  r  r  r  rD  rS  r`  rd  rf  rx  r  rz  __all__r@   rH   rI   <module>r     s  

 #    # : : J   ( O O     ,   C C B ! # 8 8 V V 7h T]t_ =.00:= Y 9  
0 '.:C$ 
!*1=F 
 
6  	 
 
 '3< 
<!O<!<! <! 	<!~ Ir1a <B	B( " !!
	
 CK(  3;'!&#+. #CK0 		(;(; <<=!!	#
 
o/9L9L1MMN!!	#	 +;2*>' > ~&~&'F 'FTq)y& q)h !z SS S8 ( ( (V #<#45  |!34  8 FG   "'#	6(  	
 
<   -2!&#	6)  	
 
:  #(!&#		6		 	 		

	 !LMQ%c*+MQb NS&2&FJ&& AF,(,9=,,:!9 !L` 
] 
 Ir1a +	  T7',/ 7 7222
2 $2 2 
26 qq
q $q q 
q qh9959	9 42

 .Y P6PPlWC Wt8( 8vF- FR	I 		Y 	E#GBK E#Py cX44 cLrH   