+
    Dfj                        R t ^ RIHt ^ RIt^ RIHtHt ^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHt ^ RIHt ]! R	4      t]! R
4      tR R ltR tR tR tR t. ROtR# )zY
Extended thread dispatching support.

For basic support see reactor threading API docs.
)annotationsN)CallableTypeVar)	ParamSpec)defer)IReactorFromThreads)failure)
ThreadPool_P_Rc               0    V ^8  d   QhRRRRRRRRR	R
RR/# )   reactorr   
threadpoolr	   fzCallable[_P, _R]argsz_P.argskwargsz	_P.kwargsreturnzdefer.Deferred[_R] )formats   ":/usr/lib/python3/dist-packages/twisted/internet/threads.py__annotate__r      sD     ' ' '' ' 	'
 ' '    c                t   a a \         P                  ! 4       oR VV 3R llpVP                  ! WR.VO5/ VB  S# )a  
Call the function C{f} using a thread from the given threadpool and return
the result as a Deferred.

This function is only used by client code which is maintaining its own
threadpool.  To run a function in the reactor's threadpool, use
C{deferToThread}.

@param reactor: The reactor in whose main thread the Deferred will be
    invoked.

@param threadpool: An object which supports the C{callInThreadWithCallback}
    method of C{twisted.python.threadpool.ThreadPool}.

@param f: The function to call.
@param args: positional arguments to pass to f.
@param kwargs: keyword arguments to pass to f.

@return: A Deferred which fires a callback with the result of f, or an
    errback with a L{twisted.python.failure.Failure} if f throws an
    exception.
c               $    V ^8  d   QhRRRRRR/# )r   successboolresultz_R | BaseExceptionr   Noner   )r   s   "r   r   'deferToThreadPool.<locals>.__annotate__9   s"     6 6$ 6(: 6t 6r   c                   < V '       d   SP                  SP                  V4       R # SP                  SP                  V4       R # N)callFromThreadcallbackerrback)r   r   dr   s   &&r   onResult#deferToThreadPool.<locals>.onResult9   s.    ""1::v6""199f5r   )r   DeferredcallInThreadWithCallback)r   r   r   r   r   r&   r%   s   f&&*, @r   deferToThreadPoolr*      s:    : "NN,A6 6 ''EdEfEHr   c                J    ^ RI Hp \        W3P                  4       V .VO5/ VB # )aT  
Run a function in a thread and return the result as a Deferred.

@param f: The function to call.
@param args: positional arguments to pass to f.
@param kwargs: keyword arguments to pass to f.

@return: A Deferred which fires a callback with the result of f,
or an errback with a L{twisted.python.failure.Failure} if f throws
an exception.
r   )twisted.internetr   r*   getThreadPool)r   r   r   r   s   &*, r   deferToThreadr/   D   s'     )W&;&;&=qR4R6RRr   c                .    V  F  w  rpV! V/ VB  K  	  R# )z
Run a list of functions.
Nr   )	tupleListr   r   r   s   &   r   _runMultipler2   U   s     %	46 %r   c                >    ^ RI Hp VP                  \        V 4       R# )zu
Run a list of functions in the same thread.

tupleList should be a list of (function, argsList, kwargsDict) tuples.
r,   N)r-   r   callInThreadr2   )r1   r   s   & r   callMultipleInThreadr5   ]   s     )y1r   c                   aaaa \         P                   ! 4       oVVVV3R lpV P                  V4       SP                  4       p\        V\        P
                  4      '       d   VP                  4        V# )aQ  
Run a function in the reactor from a thread, and wait for the result
synchronously.  If the function returns a L{Deferred}, wait for its
result and return that.

@param reactor: The L{IReactorThreads} provider which will be used to
    schedule the function call.
@param f: the callable to run in the reactor thread
@type f: any callable.
@param a: the arguments to pass to C{f}.
@param kw: the keyword arguments to pass to C{f}.

@return: the result of the L{Deferred} returned by C{f}, or the result
    of C{f} if it returns anything other than a L{Deferred}.

@raise Exception: If C{f} raises a synchronous exception,
    C{blockingCallFromThread} will raise that exception.  If C{f}
    returns a L{Deferred} which fires with a L{Failure},
    C{blockingCallFromThread} will raise that failure's exception (see
    L{Failure.raiseException}).
c                 r   < \         P                  ! S.SO5/ SB p V P                  SP                  4       R # r!   )r   maybeDeferredaddBothput)r   ar   kwqueues    r   _callFromThread/blockingCallFromThread.<locals>._callFromThread   s-    $$Q11b1uyy!r   )Queuer"   get
isinstancer   FailureraiseException)r   r   r;   r<   r>   r   r=   s   &fjl  @r   blockingCallFromThreadrE   h   sW    , KKME" " ?+YY[F&'//**Mr   )r/   r*   r5   rE   )__doc__
__future__r   r=   r@   typingr   r   r   r-   r   twisted.internet.interfacesr   twisted.pythonr   twisted.python.threadpoolr	   r
   r   r*   r/   r2   r5   rE   __all__r   r   r   <module>rM      sY    #  $  " ; " 0t_T]'TS"2 Fr   