HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/internet/__pycache__/threads.cpython-38.pyc
U


W[q�@s�dZddlmZmZddlmZes.ddlZnddlZddlm	Z	ddl
mZdd�Zd	d
�Z
dd�Zd
d�Zdd�Zd
dddgZdS)zY
Extended thread dispatching support.

For basic support see reactor threading API docs.
�)�division�absolute_import)�_PY3N)�failure)�defercs.t�����fdd�}|j||f|�|��S)a6
    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.
    cs&|r���j|�n���j|�dS�N)�callFromThread�callbackZerrback)Zsuccess�result��d�reactor��:/usr/lib/python3/dist-packages/twisted/internet/threads.py�onResult/sz#deferToThreadPool.<locals>.onResult)rZDeferredZcallInThreadWithCallback)r
Z
threadpool�f�args�kwargsrrrr�deferToThreadPoolsrcOs$ddlm}t||��|f|�|�S)aw
    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�r
)�twisted.internetr
rZ
getThreadPool)rrrr
rrr�
deferToThread:s
���rcCs|D]\}}}|||�qdS)z"
    Run a list of functions.
    Nr)�	tupleListrrrrrr�_runMultipleKsrcCsddlm}|�t|�dS)z�
    Run a list of functions in the same thread.

    tupleList should be a list of (function, argsList, kwargsDict) tuples.
    rrN)rr
ZcallInThreadr)rr
rrr�callMultipleInThreadSsrcsDt�������fdd�}|�|����}t|tj�r@|��|S)a�
    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: 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}).
    cs"tj�f����}|��j�dSr)rZ
maybeDeferredZaddBothZput)r
��ar�kw�queuerr�_callFromThreadtsz/blockingCallFromThread.<locals>._callFromThread)�Queuer�get�
isinstancerZFailureZraiseException)r
rrrrr
rrr�blockingCallFromThread]s
r#)�__doc__Z
__future__rrZtwisted.python.compatrr rZtwisted.pythonrrrrrrrr#�__all__rrrr�<module>s
$
!�