%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/internet/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/internet/__pycache__/threads.cpython-312.pyc

�

Ϫ�f�����dZddlmZddlZddlmZmZddlmZddl	m
Z
ddlmZddl
mZdd	lmZed
�Zed�Z												dd�Zd
�Zd�Zd�Zd�Zgd�Zy)zY
Extended thread dispatching support.

For basic support see reactor threading API docs.
�)�annotationsN)�Callable�TypeVar)�	ParamSpec)�defer)�IReactorFromThreads)�failure)�
ThreadPool�_P�_Rc�n���tj��d��fd�}|j||g|��i|���S)a3
    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�|��|r�j�j|�y�j�j|�y�N)�callFromThread�callback�errback)�success�result�d�reactors  ���:/usr/lib/python3/dist-packages/twisted/internet/threads.py�onResultz#deferToThreadPool.<locals>.onResult9s.�����"�"�1�:�:�v�6��"�"�1�9�9�f�5�)r�boolrz_R | BaseException�return�None)r�Deferred�callInThreadWithCallback)r�
threadpool�f�args�kwargsrrs`     @r�deferToThreadPoolr#s9���:"�N�N�,�A�6�(�J�'�'��!�E�d�E�f�E��Hrc�L�ddlm}t||j�|g|��i|��S)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�r)�twisted.internetrr#�
getThreadPool)r r!r"rs    r�
deferToThreadr(Ds)��)��W�g�&;�&;�&=�q�R�4�R�6�R�Rrc�*�|D]\}}}||i|���y)z"
    Run a list of functions.
    N�)�	tupleListr r!r"s    r�_runMultipler,Us&��%����4��	�4��6��rc�<�ddlm}|jt|�y)z�
    Run a list of functions in the same thread.

    tupleList should be a list of (function, argsList, kwargsDict) tuples.
    rr%N)r&r�callInThreadr,)r+rs  r�callMultipleInThreadr/]s��)�����y�1rc�������tj������fd�}|j|��j�}t|tj
�r|j
�|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 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�n��tj�g���i���}|j�j�yr)r�
maybeDeferred�addBoth�put)r�ar �kw�queues ����r�_callFromThreadz/blockingCallFromThread.<locals>._callFromThread�s-����$�$�Q�1��1�b�1�����u�y�y�!r)�Queuer�get�
isinstancer	�Failure�raiseException)rr r5r6r8rr7s ```  @r�blockingCallFromThreadr>hsO���,
�K�K�M�E�"����?�+�
�Y�Y�[�F��&�'�/�/�*������Mr)r(r#r/r>)rrrr
r zCallable[_P, _R]r!z_P.argsr"z	_P.kwargsrzdefer.Deferred[_R])�__doc__�
__future__rr7r9�typingrrrr&r�twisted.internet.interfacesr�twisted.pythonr	�twisted.python.threadpoolr
rrr#r(r,r/r>�__all__r*rr�<module>rFs����#��$��"�;�"�0��t�_���T�]��'
�
 �'
��'
��'
��	'
�
�'
��
'
�TS�"�2� �F�r

Zerion Mini Shell 1.0