%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__/defer.cpython-312.pyc

�

Ϫ�f���0�UdZddlmZddlZddlZddlZddlmZmZddl	m
Z
mZmZddl
mZmZddlmZddlmZdd	lmZmZdd
lmZmZmZmZddlmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1ddl2Z2ddl3m4Z4dd
lm5Z5m6Z6m7Z7m8Z8ddl9m:Z:m;Z;ddl<m=Z=ddl>m?Z?ddl@mAZAmBZBmCZCddlDmEZEmFZFddlGmHZHmIZIe=�ZJe.d�ZKe7d�ZLeAxrej�dkZNGd�deO�ZPGd�deO�ZQGd�deO�ZRGd�deS�ZTdqd�ZUdrd �ZVdsdtd!�ZW								dud"�ZXe1								dvd#��ZYe1								dwd$��ZYe1								dxd%��ZY								dyd&�ZYeEe4d'd(d)d�d*�+�dzd,��ZZd{d-�Z[d|d.�Z\d}d/�Z]d~d0�Z^dd1�Z_Gd2�d3e�Z`e`j�Zae`j�Zbe"d4ecfZde"d4ecfZee,ecd4fZfe(egecfZhe,e,e/ede6e`j�fefehfe,e/eeede6e`j�fefehffZiei�Zjd5ekd6<e.d7�Zle.d8�ZmGd9�d:�ZnGd;�d<e!el�Zo				d�d=�ZpeCGd>�d?eO��Zqe,elerfZse,etelfZue'euelZver>e1		d�									d�dA��Zwe1			d�									d�dB��Zw			d�									d�dC�ZwewZxGdD�dEeoeve �Zx	d�					d�dF�Zy	d�					d�dG�ZzGdH�dIeO�Z{d�dJ�Z|dKZ}d@Z~GdL�dM�Ze$ecddfZ�						d�dN�Z�eEe4d'dOdd�dP�				d�dQ��Z�GdR�dSe��Z�d�dT�Z�e2�jdK�U�GdV�dWe%el��Z�												d�dX�Z�eI										d�dY��Z�						d�dZ�Z�						d�d[�Z�				d�d\�Z�Gd]�d^eO�Z�				d�d_�Z�Gd`�dae�Z�Gdb�dce��Z�Gdd�dee��Z�Gdf�dgeO�Z�Gdh�dieO�Z�Gdj�dke%eK�Z�Gdl�dmeO�Z�Gdn�doe?�j,�Z�gdp�Z�y)�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�warnAboutFunction)�Failure�_extraneous�_T�_P)���c��eZdZdZy)�AlreadyCalledErrorz�
    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__�__doc__���8/usr/lib/python3/dist-packages/twisted/internet/defer.pyr=r=A���rDr=c��eZdZdZy)�CancelledErrorzJ
    This error is raised by default when a L{Deferred} is cancelled.
    Nr>rCrDrErHrHH���rDrHc��eZdZdZy)�TimeoutErrorzG
    This error is raised by default when a L{Deferred} times out.
    Nr>rCrDrErKrKNrIrDrKc��eZdZdZy)�NotACoroutineErrorzb
    This error is raised when a coroutine is expected and something else is
    encountered.
    Nr>rCrDrErMrMTrFrDrMc�2�tjd|�|S)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 rE�logErrorrS[s���K�K��C���JrDc�<�t�}|j|�|S)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.
    )�Deferred�callback��result�ds  rE�succeedrZhs���j�A��J�J�v���HrDc�<�t�}|j|�|S)a2
    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.
    )rU�errbackrWs  rE�failr]|s�� �z�A��I�I�f���HrDc�\�	||i|��}t|�S#t$r
t�cYSwxYw)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.
    )rZ�
BaseExceptionr])�callable�args�kwargsrXs    rE�executerc�s:����4�*�6�*���v�������v�
��s��+�+c��y�NrC��frarbs   rE�
maybeDeferredrh����rDc��yrerCrfs   rErhrh�s��rDc��yrerCrfs   rErhrh�rirDc�8�	||i|��}t|t�r|St|t�rt|�St
|�turtj|�S|}t|�S#t$r&tttj���cYSwxYw)a6
    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)
r_r]r5rU�debug�
isinstance�typer�
fromCoroutinerZ)rgrarbrX�returneds     rErhrh�s���<9��D�#�F�#���&�(�#��
�	�F�G�	$��F�|��	
�f���	&�$�%�%�f�-�-����x� � ��9�9��G����7�8�8�9�s�A*�*,B�B�Twisted��z*twisted.internet.defer.Deferred.addTimeout)�replacementc�J�|jttd���y)NzCallback timed out)r\r5rK)�deferreds rE�timeoutrz�s��

���W�\�*>�?�@�ArDc��|SrerC��args rE�passthrur~�����JrDc��|SrerCr|s rE�	_failthrur�rrDc�,�t|�t_y)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)�boolrUro)�ons rE�setDebuggingr�s���"�X�H�NrDc�"�tjS)z=
    Determine whether L{Deferred} debugging is enabled.
    )rUrorCrDrE�getDebuggingr�s���>�>�rDc�h�t|t�r!|jt�t	|d��|S)a�
    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
    rU)rpr5�traprHrK)�valuerzs  rE�_cancelledToTimedOutErrorr�s,���%��!�
�
�
�>�"��7�J�/�/��LrDc�,�eZdZdZe�Ze�Zy)�	_Sentinela�
    @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.
    N)r?r@rArB�object�
_NO_RESULT�	_CONTINUErCrDrEr�r�)s��	���J���IrDr�.�_CallbackKeywordArguments�_NONE_KWARGS�_SelfResultT�_NextResultTc�L�eZdZUdZdZded<dZded<dZded<d
d�Zdd	�Z	y)�	DebugInfoz 
    Deferred debug helper.
    NzOptional[Failure]�
failResultzOptional[List[str]]�creator�invokerc�R�d}|j�F|dz
}|dj|j�j�jdd�z
}|dz
}|j�F|dz
}|dj|j�j�jdd�z
}|dz
}|S)NrOz C: Deferred was created:
 C:�
z
 C:z I: First Invoker was:
 I:z
 I:)r��join�rstrip�replacer�)�self�infos  rE�_getDebugTracebackszDebugInfo._getDebugTracebacksds������<�<�#��4�4�D��B�G�G�D�L�L�)�0�0�2�:�:�4��I�I�D��D�L�D��<�<�#��1�1�D��B�G�G�D�L�L�)�0�0�2�:�:�4��I�I�D��D�L�D��rDc��|j�Qtjdd��|j�}|rd}nd}tj	||j|��yy)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}).
        NzUnhandled error in Deferred:T)�isErrorz(debug: {debugInfo})rO)�	debugInfo)r�rP�criticalr�rQ)r�r��formats   rE�__del__zDebugInfo.__del__psW���?�?�&�
�L�L�7��L�F��0�0�2�I��/�����K�K�����9�K�E�'rD��return�str�r��None)
r?r@rArBr��__annotations__r�r�r�r�rCrDrEr�r�[s5���%)�J�!�(�#'�G�
 �'�#'�G�
 �'�
�FrDr�c��eZdZUdZdZdZdZded<dZdZ	dZ
dZded<	d0			d1d	�Zdd
e
d
e
f													d2d�Ze								d3d��Ze								d4d
��Ze								d5d��Ze								d6d��Ze								d7d��Ze								d8d��Zd9d�Ze								d:d��Ze								d;d��Ze								d<d��Zd=d�Ze								d>d��Ze								d?d��Ze								d@d��Ze								dAd��Ze								dBd��Ze								dCd��Ze								dDd��Zd9d�Z	d0							dEd�ZdFd �ZdGd!�Zd0dHd"�ZdId#�ZdId$�ZdId%�ZdJd&�ZdKd'�ZdId(�ZdLd)�ZeZdMd*�Ze d0dNd+��Z!dOd,�Z"e!Z#dPd-�Z$e%dQd.��Z&e%				dRd/��Z'y)SrUa
    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}.
    FrNzOptional[DebugInfo]�
_debugInfoz'Optional[Deferred[Any]]'�
_chainedToc��g|_||_|jr6t�|_tj�dd|j_yy)aH
        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�
_cancellerror�r��	traceback�format_stackr��r��	cancellers  rE�__init__zDeferred.__init__�sC��402���#����:�:�'�k�D�O�&/�&<�&<�&>�s��&C�D�O�O�#�rDrCc���|�t}|�d}|�i}|�d}|�i}t|�sJ�t|�sJ�|jj|||f|||ff�|jr|j�|S)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}.
        rC)r�r`r��append�called�
_runCallbacks)r�rVr\�callbackArgs�callbackKeywords�errbackArgs�errbackKeywordss       rE�addCallbackszDeferred.addCallbacks�s���L�?��G����L��#�!�����K��"� �O���!�!�!��� � � �������<�)9�:��+��7�
�	
��;�;���� ��rDc��yrerC�r�rVrarbs    rE�addCallbackzDeferred.addCallback*���	rDc��yrerCr�s    rEr�zDeferred.addCallback3���	rDc��yrerCr�s    rEr�zDeferred.addCallback?r�rDc��yrerCr�s    rEr�zDeferred.addCallbackHr�rDc��yrerCr�s    rEr�zDeferred.addCallbackQr�rDc��yrerCr�s    rEr�zDeferred.addCallback]r�rDc�*�|j|||��S)z^
        Convenience method for adding just a callback.

        See L{addCallbacks}.
        )r�r��r�r�s    rEr�zDeferred.addCallbackfs��� � ���v� �V�VrDc��yrerC�r�r\rarbs    rE�
addErrbackzDeferred.addErrbackqr�rDc��yrerCr�s    rEr�zDeferred.addErrbackzr�rDc��yrerCr�s    rEr�zDeferred.addErrback�r�rDc�4�|jt|||��S)z^
        Convenience method for adding just an errback.

        See L{addCallbacks}.
        )r�r�)r�r~r�s    rEr�zDeferred.addErrback�s%��� � ��g�4��!�
�	
rDc��yrerCr�s    rE�addBothzDeferred.addBoth�r�rDc��yrerCr�s    rEr�zDeferred.addBoth�r�rDc��yrerCr�s    rEr�zDeferred.addBoth����	rDc��yrerCr�s    rEr�zDeferred.addBoth�r�rDc��yrerCr�s    rEr�zDeferred.addBoth�r�rDc��yrerCr�s    rEr�zDeferred.addBoth�r�rDc��yrerCr�s    rEr�zDeferred.addBoth�r�rDc�0�|j||||||��S)z�
        Convenience method for adding a single callable as both a callback
        and an errback.

        See L{addCallbacks}.
        )r�r�r�r�r�r�s    rEr�zDeferred.addBoth�s.��� � �����#�"�
!�
�	
rDc������	�dg�	d��	fd�}|j�|��				d��	�fd�}d�fd�}�j|�}|j|�S)a�
        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��d�d<�j�y)NTr��cancel)r��timedOuts��rE�	timeItOutz&Deferred.addTimeout.<locals>.timeItOuts����H�Q�K��K�K�MrDc�8���dr�xst}||��S|S)Nr)r�)rX�toCall�onTimeoutCancelr�rzs  ���rE�convertCancelledz-Deferred.addTimeout.<locals>.convertCancelled"s)���
��{�(�E�,E���f�g�.�.��MrDc�H���j�r�j�|Sre)�activer�)rX�delayedCalls �rE�
cancelTimeoutz*Deferred.addTimeout.<locals>.cancelTimeout,s ����!�!�#��"�"�$��MrDr�)rX�Union[_SelfResultT, Failure]r�z*Union[_SelfResultT, _NextResultT, Failure])rXr7r�r7)�	callLaterr�)
r�rz�clockr�r�r�r��	convertedr�r�s
`` `    @@rE�
addTimeoutzDeferred.addTimeout�sg���N�7��	��o�o�g�y�9��	�0�	�
7�	�	�BF����B
�	�� � ��/�/rDc�\�||_|j|j|j�S)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�rVr\�r�rYs  rE�
chainDeferredzDeferred.chainDeferred:s&��0���� � ����Q�Y�Y�7�7rDc�J�t|t�rJ�|j|�y)a7
        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)rprU�_startRunCallbacks)r�rXs  rErVzDeferred.callbackUs"��.�f�h�/�/�/�����'rDc��|�t|j��}nt|t�st|�}|j|�y)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.
        Nrm)r5rorpr�)r�r]s  rEr\zDeferred.errbackos9��@�<��t�z�z�2�D��D�'�*��4�=�D�����%rDc�,�|jdz|_y)zP
        Stop processing on a L{Deferred} until L{unpause}() is called.
        rvN)�paused�r�s rE�pausezDeferred.pause�s���k�k�A�o��rDc��|jdz
|_|jry|jr|j�yy)zI
        Process all callbacks made since L{pause}() was called.
        rvN)r�r�r�r�s rE�unpausezDeferred.unpause�s5���k�k�A�o����;�;���;�;���� �rDc�"�|jsN|j}|r	||�nd|_|js#|jt	t���yyt
|jt�r|jj�yy)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��_suppressAlreadyCalledr\r5rHrprXrUr�r�s  rEr�zDeferred.cancel�so���{�{����I���$��/3��+��;�;����W�^�%5�6�7������X�
.��K�K��� �/rDc���|jri|jrd|_y|jrC|j�t	�|_d|jj�z}t
|��t�|jrA|j�t	�|_tj�dd|j_	d|_d|_
||_|j�y)NFr����T)
r�r�ror�r�r�r=r�r�r�r�rXr�)r�rX�extras   rEr�zDeferred._startRunCallbacks�s����;�;��*�*�.3��+���z�z��?�?�*�&/�k�D�O��t���B�B�D�D��(��/�/�$�$��:�:����&�"+�+���&/�&<�&<�&>�s��&C�D�O�O�#�������������rDc�b�tj|ftftj|ftffS)zT
        Build a tuple of callback and errback with L{_Sentinel._CONTINUE}.
        )r�r�r�r�s rE�
_continuationzDeferred._continuation�s2��
�
 �
 �4�'�<�8�
�
 �
 �4�'�<�8�
�	
rDc�b�|jry|g}|�r�|d}|jryd}d|_|j�r|jj	d�}t|jt�s
|d\}}}n	|d\}}}|turyttt|d�}|j|_d|_|j�d|j_
|xjdzc_|j|�d}�nV	d|_	||jg|��i|��|_|j|urt|d�d|_	t|jt�r�t!|jdt"�}	|	t"us&t|	t�s|jjrU|j%�|j|_|jjj|j'��nXd|j_|jj�d|jj_
|	|_	|jr��|r�t|jt�rQ|jj-�|j�t/�|_|j|j_
n|j�d|j_
|j	�|r���yy#d|_wxYw#t($rt|j*�	�|_Y��wxYw)
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�TrrvFz|Callback returned the Deferred it was attached to; this breaks the callback chain and will raise an exception in the future.rXrm)�_runningCallbacksr�r�r��poprprXr5r�r%rUr�r�r�r�r4�getattrr�r�rr_ro�cleanFailurer�)
r��chain�current�finished�itemrVrarb�chainee�resultResults
          rEr�zDeferred._runCallbacks�s���4�!�!��'+�V����B�i�G��~�~���H�!%�G���#�#��(�(�,�,�Q�/��!�'�.�.�'�:�-1�!�W�*�H�d�F�.2�!�W�*�H�d�F��y�(�#�8�F�#3�T�!�W�=�G�%,�^�^�G�N�%)�G�N��)�)�5�8<��*�*�5��N�N�a�'�N��L�L��)� %�H��4:�04�G�-�:�*2�#�N�N�*�-1�*�5;�*���#�>�>�W�4�-� (�!;��5:��1�"�'�.�.�(�;�(/�w�~�~�x��'T��(�J�6�)�,��A�&�~�~�4�4�$�M�M�O�18���G�.�
$�N�N�4�4�;�;�G�<Q�<Q�<S�T�!�59�G�N�N�1�&�~�~�8�8�D�GK���� 9� 9� D�-9�G�N�]�#�#�`�
�g�n�n�g�6��N�N�/�/�1��)�)�1�-6�[��*�4;�N�N�G�&�&�1��)�)�5�8<��*�*�5��	�	��_��v5:��1��$�E�&-����%D�G�N�E�s*�L�5K;�L�;	L�L�$L.�-L.c���|jj}t|dt�}t	|�}|j
�dt	|j
�d��}n|turd}nd|��}d|�d|d�|�d�S)	zE
        Return a string representation of this L{Deferred}.
        rXz waiting on Deferred at 0x�xrOz current result: �<z at 0x�>)�	__class__r?rr��idr�)r��cnamerX�myIDs    rE�__str__zDeferred.__str__ys������'�'����x��4���$�x���?�?�&�1�"�T�_�_�2E�a�1H�I�F�
�z�
!��F�(��
�3�F��5�'���Q�x��x�q�1�1rDc��|SrerCr�s rE�__iter__zDeferred.__iter__�s���rDc��|jr|St|dt�}|tur|St|t�r<|j
�J�d|j
_||j_|j�t|��)NrX)
r�rr�rpr5r�r�r��__failure__�
StopIteration)r�r�rXs   rE�sendz
Deferred.send�sr���;�;��K���x��4���Z���K��f�g�&��?�?�.�.�.�)-�D�O�O�&�'-�F�L�L�$��,�,����'�'rDc�"�|j�Sre)rr�s rE�	__await__zDeferred.__await__�s���}�}��rDc����|j��d�fd�}d�fd�}d�fd�}�j||��j|��S)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�H��|j�r�j�yyre)�	cancelledr�)�futureAgainr�s �rE�checkCancelz&Deferred.asFuture.<locals>.checkCancel�s����$�$�&����
�'rDc�^���j�s�j|j�yyre)r#�
set_exceptionr�)rQ�futures �rE�	maybeFailz$Deferred.asFuture.<locals>.maybeFail�s&����#�#�%��$�$�W�]�]�3�&rDc�J���j�s�j|�yyre)r#�
set_result)rXr(s �rE�maybeSucceedz'Deferred.asFuture.<locals>.maybeSucceed�s"����#�#�%��!�!�&�)�&rD)r$�'Future[_SelfResultT]'r�r�)rQr5r�r��rXr�r�r�)�
create_futurer��add_done_callback)r��loopr%r)r,r(s`    @rE�asFuturezDeferred.asFuture�sG����#�#�%��	�	4�	*�	
���,�	�2�� � ��-��
rDc�����d�fd�}t��d��fd�}||�}|�				d��fd�}|j|��j|�|S)a�
        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�|��	|j�}�j|�y#t$r
t�}Y�'wxYwre)rXr_r5rV)rX�	extracted�actuals  �rE�adaptz"Deferred.fromFuture.<locals>.adapt�s9���
&�4:�M�M�O�	�
�O�O�I�&��!�
&�#�I�	�
&�s�%�;�;c�H���j�|j��yre�r�rV)�reselfr(�futureCancels ��rEr�z#Deferred.fromFuture.<locals>.cancel�s����M�M�O��O�O�L�)rDc�(��|�urt���S|Sre)rU)rXr6r;s ��rE�uncancelz%Deferred.fromFuture.<locals>.uncancel�s�����%�!����
��MrD)rXzFuture[_SelfResultT]r�r�)r:�Deferred[object]r�r�)rXr�r�z+Union[_SelfResultT, Deferred[_SelfResultT]])r�r�r0)�clsr(r7r�r�r=r6r;s `    @@rE�
fromFuturezDeferred.fromFuture�s^���(	'��x��	*��6�{����	� �	�
8�	�	
����"�� � ��'��rDc�t�t|�stj|�rt|�St	|�d���)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�_cancellableInlineCallbacksrM)r?�coros  rErrzDeferred.fromCoroutine�s8��\�t��� 3� 3�D� 9�.�t�4�4� �D�8�+>�!?�@�@rDre)r�z+Optional[Callable[['Deferred[Any]'], None]]r�r�)rVz�Union[Callable[..., _NextResultT], Callable[..., Deferred[_NextResultT]], Callable[..., Failure], Callable[..., Union[_NextResultT, Deferred[_NextResultT], Failure]]]r\z�Union[Callable[..., _NextResultT], Callable[..., Deferred[_NextResultT]], Callable[..., Failure], Callable[..., Union[_NextResultT, Deferred[_NextResultT], Failure]], None]r�zTuple[Any, ...]r�zMapping[str, Any]r��_CallbackOrderedArgumentsr�r�r�z'Deferred[_NextResultT]')rVz0Callable[Concatenate[_SelfResultT, _P], Failure]ra�_P.argsrb�	_P.kwargsr��Deferred[_NextResultT])rVzOCallable[Concatenate[_SelfResultT, _P], Union[Failure, Deferred[_NextResultT]]]rarGrbrHr�rI)rVzECallable[Concatenate[_SelfResultT, _P], Union[Failure, _NextResultT]]rarGrbrHr�rI)rVz?Callable[Concatenate[_SelfResultT, _P], Deferred[_NextResultT]]rarGrbrHr�rI)rVzTCallable[Concatenate[_SelfResultT, _P], Union[Deferred[_NextResultT], _NextResultT]]rarGrbrHr�rI)rVz5Callable[Concatenate[_SelfResultT, _P], _NextResultT]rarGrbrHr�rI)rVrrarrbrr��'Deferred[Any]')r\z:Callable[Concatenate[Failure, _P], Deferred[_NextResultT]]rarGrbrHr��-'Deferred[Union[_SelfResultT, _NextResultT]]')r\z+Callable[Concatenate[Failure, _P], Failure]rarGrbrHr�z'Deferred[Union[_SelfResultT]]')r\z0Callable[Concatenate[Failure, _P], _NextResultT]rarGrbrHr�rK)r\rrarrbrr�rJ)rVz@Callable[Concatenate[Union[_SelfResultT, Failure], _P], Failure]rarGrbrHr�rI)rVz_Callable[Concatenate[Union[_SelfResultT, Failure], _P], Union[Failure, Deferred[_NextResultT]]]rarGrbrHr�rI)rVzUCallable[Concatenate[Union[_SelfResultT, Failure], _P], Union[Failure, _NextResultT]]rarGrbrHr�rI)rVzOCallable[Concatenate[Union[_SelfResultT, Failure], _P], Deferred[_NextResultT]]rarGrbrHr�rI)rVzdCallable[Concatenate[Union[_SelfResultT, Failure], _P], Union[Deferred[_NextResultT], _NextResultT]]rarGrbrHr�rI)rVzECallable[Concatenate[Union[_SelfResultT, Failure], _P], _NextResultT]rarGrbrHr�rI)rVz!Callable[Concatenate[_T, _P], _T]rarGrbrHr��Deferred[_SelfResultT])rz�floatr�r-r�zWOptional[Callable[[Union[_SelfResultT, Failure], float], Union[_NextResultT, Failure]]]r�rK)rY�'Deferred[_SelfResultT]'r�z'Deferred[None]')rXr�r�r�)r]�'Optional[Union[Failure, BaseException]]r�r�r�r.)r��_CallbackChainr�)r�rN)r�r�r�rN)r�z"Generator[Any, None, _SelfResultT])r1rr�r-)r(r-r�rN)rEzKUnion[Coroutine[Deferred[Any], Any, _T], Generator[Deferred[Any], Any, _T]]r��'Deferred[_T]')(r?r@rArBr�r�r�r�r�rror�r�r�r�r&r�r�r�r�r�rVr\r�r�r�r�rr�r�__repr__rr6rr �__next__r2�classmethodr@rrrCrDrErUrU�s^��"�H�F�
�F�&*�J�#�*�"��
��
�E�,0�J�)�0�HL�D�D�D�	
�D�h
�(*�.:�13�5A�1B�
�B�	
�B�*&�+B�,,�-B�./�/B�03�1B�2
"�3B�`��B�����	�

 �����	�
�	��
	��	�
 �	��	���W�����	�

 ������Q�����	�

 �����	�
�	��
	��	�
 �	��	���G�����	�

 ����	W���K�����	�

7������<�����	�

)������A�����	�

7����	
���R�����	�

 �����	�
�	��
	��	�
 �	��	���
��
���
�
 ������
��
���
�
 �����	�
�	��
	��	�
 �	��	���W�����	�

 ������3�����	�

 ����
�8
�E0��E0��E0�
�	E0�
7�E0�N8�6(�4%&�N&�!�!�8�0
�T�l
2��H���(��(�0��H� �D�/��/�b�/A�
�/A�
�
/A��/ArDrUc��t|t�r|S	tj|�S#t$rt|�d���wxYw)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)rprUrrrM)rEs rE�ensureDeferredrV2sP��"�$��!���	S��)�)�$�/�/��!�	S�%��x�/P�%Q�R�R�	S�s	�)�Ac�0�eZdZdZdd�Zdd�Zdd�Zd	d�Zy)
�
FirstErrorz�
    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�N�tj|||�||_||_yre)�	Exceptionr��
subFailure�index)r�rQr\s   rEr�zFirstError.__init__Xs"�����4��%�0�!�����
rDc�L�d|j|jjfzS)z�
        The I{repr} of L{FirstError} instances includes the repr of the
        wrapped failure's exception and the index of the L{FirstError}.
        zFirstError[#%d, %r])r\r[r�r�s rErRzFirstError.__repr__]s"��
%��
�
�D�O�O�4I�4I�'J�J�JrDc�8�d|j|jfzS)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}.
        zFirstError[#%d, %s])r\r[r�s rErzFirstError.__str__ds��%��
�
�D�O�O�'D�D�DrDc��t|t�r8t|j|jf|j|jf�Sy)a+
        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�)rprXr1r\r[)r��others  rE�__cmp__zFirstError.__cmp__ls:���e�Z�(���
�
�D�O�O�4�u�{�{�E�DT�DT�6U�V�V�rDN)rQr5r\�intr�r�r�)r`r�r�rb)r?r@rArBr�rRrrarCrDrErXrXNs����
K�E�rDrXFc��yrerC��deferredList�fireOnOneCallback�fireOnOneErrback�
consumeErrorss    rE�
_DeferredListri�r�rDc��yrerCrds    rEriri�r�rDc��yrerCrds    rEriri�r�rDc�V�eZdZdZdZdZ			d							dd�Z								d	d�Zd
d�Zy)�DeferredLista)
    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��t|�|_dgt|j�z|_	tj|�t|j�dk(r|s|j
g�||_||_||_	d|_
d}|jD]<}|j|j|j|tf|tf��|dz}�>y)aj
        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�rv)�list�
_deferredList�len�
resultListrUr�rVrfrgrh�
finishedCountr��_cbDeferred�SUCCESS�FAILURE)r�rerfrgrhr\rys       rEr�zDeferredList.__init__�s���B"�,�/���
KO��RU����S
�J
���	�	���$���t�!�!�"�a�'�0A��M�M�"��
"3��� 0���*���������*�*�	�H��!�!�� � �� � �#�W�-�"�G�,�	
"�
��A�I�E�	rDc�$�||f|j|<|xjdz
c_|js�|tk(r |jr|j||f�n�|tk(rC|jr7t|t�sJ�|jtt||���nR|jt|j�k(r0|jttt|j��|tk(r
|j ry|S)zI
        (internal) Callback for when one of my deferreds fires.
        rvN)rsrtr�rvrfrVrwrgrpr5r\rXrrr%�_DeferredListResultListTrrh)r�rXr\�	succeededs    rEruzDeferredList._cbDeferreds���#,�V�!4���������a����{�{��G�#��(>�(>��
�
�v�u�o�.��g�%�$�*?�*?�!�&�'�2�2�2����W�Z���%>�?�@��#�#�s�4�?�?�';�;��
�
�d�#;�C�#@�$�/�/�R�S����D�$6�$6���
rDc��|js#|jD]}	|j��yy#t$rtjd�Y�8wxYw)a�
        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�rqr�r_rPrQ)r�rys  rEr�zDeferredList.cancel sW���{�{� �.�.�
Q��Q��O�O�%�
Q���%�Q��K�K� O�P�Q�s�1�A�AN�FFF)re� Iterable[Deferred[_SelfResultT]]rfr�rgr�rhr�)rXr�r\rbrzr�r�zOptional[_SelfResultT]r�)	r?r@rArBrfrgr�rur�rCrDrErmrm�s|���,����
#(�!&�#�D�6�D� �D��	D�
�D�L�"��+.��;?��	��4QrDrmc�\�	|D]}|�J�|\}}|r�J�|D�cgc]}|d��	c}Scc}w)NrvrC)rsrgrX�successr�rs      rE�_parseDeferredListResultr�4sL��� �	�F��%�%�%�#�N�G�U��N�7�	�%�%�Q�A�a�D�%�%��%s�)c�D�t|d|��jt�S)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)rgrh)rmr�r�)rerhs  rE�
gatherResultsr�?s#��0��t�=���k�*�+�,rDc�$��eZdZdZd�fd�Z�xZS)�FailureGroupz)
    More than one failure occurred.
    c�8��tt|��||_yre)�superr�r��failures)r�r�rs  �rEr�zFailureGroup.__init__as���
�l�D�*�,� ��
rD)r�zSequence[Failure]r�r�)r?r@rArBr��
__classcell__)rs@rEr�r�\s����!�!rDr�c������	�d�	d�fd�}t|���d���	fd�}g�d	���fd�}t|��t|�D]\}}|j|||f|f����S)
aV
    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�4���D]}|j��yrer�)rXrY�	to_cancels  �rEr�zrace.<locals>.cancelxs���
�	�A�
�H�H�J�	rD�r�c�t����5�|��D]}|�us�|j���j||f�yyrer9)�this_output�
this_indexrY�final_resultr��winners   ���rErzzrace.<locals>.succeeded�sO����>��z�*�F��
���F�?��H�H�J�
�

�!�!�:�{�";�<�rDc�����j||f�t��t��k(r?�j��D��cgc]\}}|��	}}}�jt	|��yycc}}wre)r�rr�sortr\r�)rQr��ignoredrgr��
failure_stater�r�s     ���rE�failedzrace.<locals>.failed�sg������j�'�2�3��}���Y��/���� �.;�<�l�w���<�H�<�� � ��h�!7�8�	0��=s�A,ro)rX�Deferred[_T]r�r�)r�r7r�rbr�r�)rQr5r�rbr�r�)rUrp�	enumerater�)
�dsr�rzr�r\rYr�r�r�r�s
      @@@@rE�racer�fsr���&*�F��.6��-G�L�=�0�M�9��R��I��b�M�W���q�	
���y�&��x�e�X��V�	W��rDTc�0�eZdZUdZeZded<dd�Zdd�Zy)	�waitForDeferred�#
    See L{deferredGenerator}.
    rrXc��tjdtd��t|t�std|�d���||_y)Nz�twisted.internet.defer.waitForDeferred was deprecated in Twisted 15.0.0; please use twisted.internet.defer.inlineCallbacks instead�)�
stacklevelz6You must give waitForDeferred a Deferred. You gave it �.)�warnings�warn�DeprecationWarningrprU�	TypeErrorrYr�s  rEr�zwaitForDeferred.__init__�sI���
�
�
�
��	
��!�X�&��H���Q�O��
���rDc��t|jt�r|jj�|jtu|jSre)rprXr5�raiseExceptionr�r�s rE�	getResultzwaitForDeferred.getResult�s6���d�k�k�7�+��K�K�&�&�(����:�%��{�{�rDN)rYr>r�r�)r�r)	r?r@rArBr�rXr�r�r�rCrDrEr�r��s����F�C��
�rDr�c�����d}ddg�		t��}t|t�rttd��St|t�rPtt|�f					d���fd�
}|jj|��drd�d<�Sd�d<d�d<d}��#t$r�j|��cYSt$r�j	��cYSwxYw)	r�NTrvz Yield waitForDeferred(d), not d!c�L��||_�drd�d<|�d<yt���y)NrFrv)rX�_deferGenerator)�rrXry�g�waitings  ���rE�	gotResultz"_deferGenerator.<locals>.gotResults/���!"��
��1�:�!&�G�A�J�!"�G�A�J�#�A�x�0rDrF)r�r�rXr�r�r�)
�nextrrVr_r\rprUr]r�r�r%rYr�)r�ryrXr�r�s``  @rEr�r��s�����F����G�
�	��!�W�F��f�h�'��	�"D�E�F�F��f�o�.�6:�/�6�5R�
1��
1�#2�
1��
1�
�H�H���Y�'��q�z�#���
����G�A�J��G�A�J��F�S���	����f�%��O��	������O�	�s�B�C�:C�C�z&twisted.internet.defer.inlineCallbacksc�0��t��d�fd��}|S)aI

    L{deferredGenerator} and L{waitForDeferred} help you write
    L{Deferred}-using code that looks like a regular sequential function.
    Consider the use of L{inlineCallbacks} instead, which can accomplish
    the same thing in a more concise manner.

    There are two important functions involved: L{waitForDeferred}, and
    L{deferredGenerator}.  They are used together, like this::

        @deferredGenerator
        def thingummy():
            thing = waitForDeferred(makeSomeRequestResultingInDeferred())
            yield thing
            thing = thing.getResult()
            print(thing) #the result! hoorj!

    L{waitForDeferred} returns something that you should immediately yield; when
    your generator is resumed, calling C{thing.getResult()} will either give you
    the result of the L{Deferred} if it was a success, or raise an exception if it
    was a failure.  Calling C{getResult} is B{absolutely mandatory}.  If you do
    not call it, I{your program will not work}.

    L{deferredGenerator} takes one of these waitForDeferred-using generator
    functions and converts it into a function that returns a L{Deferred}. The
    result of the L{Deferred} will be the last value that your generator yielded
    unless the last value is a L{waitForDeferred} instance, in which case the
    result will be L{None}.  If the function raises an unhandled exception, the
    L{Deferred} will errback instead.  Remember that C{return result} won't work;
    use C{yield result; return} in place of that.

    Note that not yielding anything from your generator will make the L{Deferred}
    result in L{None}. Yielding a L{Deferred} from your generator is also an error
    condition; always yield C{waitForDeferred(d)} instead.

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

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

    Put succinctly, these functions connect deferred-using code with this 'fake
    blocking' style in both directions: L{waitForDeferred} converts from a
    L{Deferred} to the 'blocking' style, and L{deferredGenerator} converts from the
    'blocking' style to a L{Deferred}.
    c�8��t�|i|��t��Sre)r�rU)rarbrgs  �rE�unwindGeneratorz*deferredGenerator.<locals>.unwindGeneratorWs����q�$�1�&�1�8�:�>�>rD)rar�rbr�r�r>r�rgr�s` rE�deferredGeneratorr�s$���x�1�X�?��?��rDc��eZdZdd�Zy)�_DefGen_Returnc��||_yre)r�)r�r�s  rEr�z_DefGen_Return.__init__bs	����
rDN)r�r�r�r�)r?r@rAr�rCrDrEr�r�as��rDr�c��t|��)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 rE�returnValuer�fs����
�rD)�auto_attribsc�*�eZdZUdZded<dZded<y)�_CancellationStatusa,
    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)
    rLryNz Optional[Deferred[_SelfResultT]]�	waitingOn)r?r@rArBr�r�rCrDrEr�r�vs���%�$�26�I�/�6rDr�c�@�|drd|d<||d<yt||||�y)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
    rFrvN)�_inlineCallbacks)r�r��gen�status�contexts     rE�_gotResultInlineCallbacksr��s+��(�q�z����
����
���C���1rDc�D�ddg}d}d}		t|t�}|r+|jtt|�j|�}n|j|j
|�}|r|j,j1|�yt|t2�r:|j5t6||||�|d
r
d|d
<||_y|d}d|d
<d|d<��#t$r}d}t|dd�}Yd}~��d}~wt$�r�}t�}	|	�J�|	d}
|
�J�|
j}|�J�tr|j}|�J�r|j}|�J�|j�J�|jjr�|}|�J�|j�J�|jjr'|j}|�J�|jjr�'|jjj}
|j}|j�J�|j�J�t!j"d|jjj$�d|jjj$�d	�t&|
|�d}|j(}Yd}~��d}~wt*$r|j,j/�YywxYw)ar
    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
    TNFrvr�r�zreturnValue() in z	 causing zX to exit: returnValue should only be invoked by functions decorated with inlineCallbacksr)rpr5�runr%�throwExceptionIntoGeneratorrrrr�r�tb_next�
_oldPypyStack�tb_frame�f_code�co_filename�	tb_linenor��
warn_explicit�co_namer�r�r_ryr\rVrUr�r�r�)rXr�r�r�r��
stopIteration�
callbackValue�	isFailure�e�excInfor��appCodeTrace�
ultimateTrace�filename�linenos               rEr�r��s���H���G��M��M�
�Z	�"�6�7�3�I�� �����&�)�E�E�s���!���S�X�X�v�6��f�
�O�O�$�$�]�3���f�h�'��N�N�4�g�s�F�G�T��q�z�#���
�#)�� ���Q�Z�F��G�A�J��G�A�J�k���	6� �M�#�A�w��5�M���G	$��j�G��&�&�&���
�I��(�(�(�$�,�,�L��+�+�+�� ,�3�3��#�/�/�/�� ,�3�3��#�/�/�/� �'�'�3�3�3��#�#�+�+�
!-�
�$�0�0�0�$�,�,�8�8�8�#�+�+�3�3�$1�$9�$9�M�(�4�4�4�$�+�+�3�3�)�1�1�8�8�D�D��&�0�0��$�-�-�9�9�9�#�,�,�8�8�8��&�&�
&�.�.�5�5�=�=�$�-�-�4�4�<�<��'����!�M��G�G�M���	��O�O�#�#�%��	�s2�AC
�
	J�C*�*
J�7CI6�;B5I6�6&J�Jc��g|jc|_}|jt|�}|jj|�|j	t��y)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�extendr\�&_InternalInlineCallbacksCancelledError)�itr��tmps   rE�_addCancelCallbackToDeferredr�AsI���B�L�L��B�L�#�	���3�V�	<�B��L�L������J�J�5�7�8rDc���|jt�t�fd���_�j}|�J�|j��jS)a�
    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���t|��Sre�r��rYr�s �rE�<lambda>z._handleCancelInlineCallbacks.<locals>.<lambda>_s���)E�a��)P�rD)r�r�rUryr�r�)rXr��awaiteds ` rEr�r�QsL����K�K�6�7��P�Q�F�O����G������N�N���?�?�rDc�f��t�fd��}t|��td|�t��|S)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���t|��Srer�r�s �rEr�z-_cancellableInlineCallbacks.<locals>.<lambda>ys���0L�Q�PV�0W�rDN)rUr�r��
_copy_context)r�ryr�s  @rErDrDjs/���&�&W�X�H�
 ��
*�F��T�3��
��8��OrDc��eZdZdZy)r�z�
    A unique exception used only in L{_cancellableInlineCallbacks} to verify
    that an L{inlineCallbacks} is being cancelled as expected.
    Nr>rCrDrEr�r��rFrDr�c�0��t��d�fd��}|S)a

    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). Note that
    you can't use C{return result} to return a value; use C{returnValue(result)}
    instead. Falling off the end of the generator, or simply using C{return}
    will cause the L{Deferred} to have a result of L{None}.

    Be aware that L{returnValue} will not accept a L{Deferred} as a parameter.
    If you believe the thing you'd like to return could be a L{Deferred}, do
    this::

        result = yield result
        returnValue(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
                returnValue('TWISTED IS GREAT!')
            else:
                # will trigger an errback
                raise Exception('DESTROY ALL LIFE')

    It is possible to use the C{return} statement instead of L{returnValue}::

        @inlineCallbacks
        def loadData(url):
            response = yield makeRequest(url)
            return json.loads(response)

    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���	�|i|��}t|t�std��d|����t	|�S#t$rtd��d���wxYw)NzinlineCallbacks requires zP to produce a generator; insteadcaught returnValue being used in a non-generatorz% to produce a generator; instead got )r�r�rprrD)rarbr�rgs   �rEr�z(inlineCallbacks.<locals>.unwindGenerator�sn���	��T�$�V�$�C��#�}�-��$%�s�,��
�+�3�/�/���	��FG�J��
�	�s	�7�A)rarGrbrHr�r�rr�s` rE�inlineCallbacksr��s$���|�1�X�
0��
0��rDc���eZdZdd�Zd
d�Ze										dd��Ze										dd��Ze										dd��Z										dd�Zdd�Z								dd�Ze	dd	��Z
e	dd
��Zy)�_ConcurrencyPrimitivec��g|_yre)r�r�s rEr�z_ConcurrencyPrimitive.__init__�s	��-/��rDc�&�|j�|Sre)�release)r�r�s  rE�_releaseAndReturnz'_ConcurrencyPrimitive._releaseAndReturn�s�������rDc��yrerC�r�rgrarbs    rEr�z_ConcurrencyPrimitive.run����	rDc��yrerCr�s    rEr�z_ConcurrencyPrimitive.run�r�rDc��yrerCr�s    rEr�z_ConcurrencyPrimitive.run�s��	rDc�Z�����d����fd�}�j�j|�S)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�g���i���j�j�Sre)rhr�r�)�
ignoredResultrargrbr�s ����rErcz*_ConcurrencyPrimitive.run.<locals>.execute	s0���!��4�T�4�V�4�<�<��&�&��
rD)r�r�r�r�)�acquirer�)r�rgrarbrcs```` rEr�z_ConcurrencyPrimitive.run�s&���*	�	��|�|�~�)�)�'�2�2rDc�"�|j�S)zD
        We can be used as an asynchronous context manager.
        )r�r�s rE�
__aenter__z _ConcurrencyPrimitive.__aenter__	s���|�|�~�rDc�8�|j�td�S)NF)r�rZ)r��_ConcurrencyPrimitive__exc_type� _ConcurrencyPrimitive__exc_value� _ConcurrencyPrimitive__tracebacks    rE�	__aexit__z_ConcurrencyPrimitive.__aexit__"	s��	
�����u�~�rDc��yrerCr�s rEr�z_ConcurrencyPrimitive.acquire-	���rDc��yrerCr�s rEr�z_ConcurrencyPrimitive.release1	rrDN�r�r+r�r�)r�r7r�r7)
rg�Callable[_P, Deferred[_T]]r�r+rarGrbrHr�r�)
rg�/Callable[_P, Coroutine[Deferred[Any], Any, _T]]r�r+rarGrbrHr�r�)
rg�Callable[_P, _T]r�r+rarGrbrHr�r�)
rg�HCallable[_P, Union[Deferred[_T], Coroutine[Deferred[Any], Any, _T], _T]]r�r+rarGrbrHr�r��r�r+r��Deferred[Self])rzOptional[Type[BaseException]]rzOptional[BaseException]rzOptional[TracebackType]r�zDeferred[Literal[False]]r�)r?r@rAr�r�r&r�r�rrr�r�rCrDrEr�r��s^��0����&�����	�
��
�
�����;�����	�
��
�
�����*����3:��FO��	����
3�T�3��3��	3�
�3�
�
3�<�	�1�	�-�	�-�		�

"�	��
��
��
��
rDr�c�,�eZdZdZdZdd�Zdd�Zd	d�Zy)
�DeferredLockz�
    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�:�|jj|�y�a�
        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  rE�_cancelAcquirezDeferredLock._cancelAcquireA	���	
�����A�rDc��t|j��}|jr|jj	|�|Sd|_|j|�|S)aL
        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)rUr�lockedr�r�rVr�s  rEr�zDeferredLock.acquireO	sN��%�t�/B�/B�C���;�;��L�L����"����D�K�
�J�J�t���rDc��|jsJd��d|_|jr4d|_|jjd�}|j|�yy)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 lockFTrN)rr�rrVr�s  rEr�zDeferredLock.release`	sP���{�{�?�?�?�{�����<�<��D�K���� � ��#�A�
�J�J�t��	rDN�r�r+rYrr�r�r
r)r?r@rArBrrr�r�rCrDrErr6	s����F���"rDrc�0�eZdZdZdd�Zdd�Zd	d�Zd
d�Zy)�DeferredSemaphorea�
    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�j�tj|�|dkrtd��||_||_y)ze
        @param tokens: initial value of L{tokens} and L{limit}
        @type tokens: L{int}
        rvz&DeferredSemaphore requires tokens >= 1N)r�r��
ValueError�tokens�limit)r�rs  rEr�zDeferredSemaphore.__init__~	s3��
	�&�&�t�,��A�:��E�F�F������
rDc�:�|jj|�yrrr�s  rErz DeferredSemaphore._cancelAcquire�	rrDc��|jdk\sJd��t|j��}|js|jj	|�|S|jdz
|_|j|�|S)zq
        Attempt to acquire the token.

        @return: a L{Deferred} which fires on token acquisition.
        rz9Internal inconsistency??  tokens should never be negativer�rv)rrUrr�r�rVr�s  rEr�zDeferredSemaphore.acquire�	st��
�K�K�1��	G�F�	G��$�t�/B�/B�C���{�{��L�L����"����+�+��/�D�K�
�J�J�t���rDc��|j|jksJd��|jdz|_|jrA|jdz
|_|jjd�}|j	|�yy)z�
        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!rvrN)rr r�rrVr�s  rEr�zDeferredSemaphore.release�	sp��
�K�K�$�*�*�$�	B�A�	B�$��k�k�A�o����<�<��+�+��/�D�K���� � ��#�A�
�J�J�t��	rDN)rrbr�r�rr
r)r?r@rArBr�rr�r�rCrDrErrq	s��
�	���"rDrc��eZdZy)�
QueueOverflowN�r?r@rArCrDrEr%r%�	���rDr%c��eZdZy)�QueueUnderflowNr&rCrDrEr)r)�	r'rDr)c�>�eZdZdZ	d					dd�Zd	d�Zd
d�Zdd�Zy)�
DeferredQueuea�
    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�<�g|_g|_||_||_yre)r��pending�size�backlog)r�r.r/s   rEr�zDeferredQueue.__init__�	s ��,.���!#�����	���rDc�:�|jj|�y)a�
        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.
        Nrr�s  rE�
_cancelGetzDeferredQueue._cancelGet�	rrDc��|jr+|jjd�j|�y|j�"t	|j
�|jkr|j
j
|�yt��)zq
        Add an object to this queue.

        @raise QueueOverflow: Too many objects are in this queue.
        rN)r�rrVr.rrr-r�r%)r��objs  rE�putzDeferredQueue.put�	s`���<�<��L�L���Q��(�(��-�
�Y�Y�
�#�d�l�l�"3�d�i�i�"?��L�L����$��/�!rDc�8�|jr$t|jjd��S|j�"t	|j
�|jkr3t
|j��}|j
j|�|St��)a3
        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.
        rr�)
r-rZrr/rrr�rUr1r�r)r�s  rE�getzDeferredQueue.get�	sq���<�<��4�<�<�+�+�A�.�/�/�
�\�\�
!�S����%6����%E�&����A�A��L�L����"��H� �"�"rD)NN)r.�
Optional[int]r/r7r�r�)rYr�r�r�)r3r7r�r�)r�r�)r?r@rArBr�r1r4r6rCrDrEr+r+�	s:���"DH��!��3@��	
���"�#rDr+c��eZdZdZy)�AlreadyTryingToLockErrorz{
    Raised when L{DeferredFilesystemLock.deferUntilLocked} is called twice on a
    single L{DeferredFilesystemLock}.
    Nr>rCrDrEr9r9

rFrDr9c�F�eZdZUdZdZdZded<dZded<d	d
d�Zd	dd�Z	y)�DeferredFilesystemLockaj
    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.
    rvNzOptional[IDelayedCall]�_tryLockCall�_timeoutCallc��tjj||�|�ddlm}tt|�}||_y)z�
        @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    rEr�zDeferredFilesystemLock.__init__$
s6��
	���(�(��t�4���0��\�7�3�I�#��rDc��������j�ttd��Sd��fd��t�fd���d�����fd�����S)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�X���j�J��jj�d�_�j�;�jj�r!�jj�d�_�j	�r�jd�y�j
|�y)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��lockrVr\)�reasonrYr�s ��rE�_cancelLockz<DeferredFilesystemLock.deferUntilLocked.<locals>._cancelLockF
s�����$�$�0�0�0����$�$�&� $�D��� � �,��1B�1B�1I�1I�1K��!�!�(�(�*�$(��!��y�y�{��
�
�4� ��	�	�&�!rDc�$���t��Sre)rH)ryrIs �rEr�z9DeferredFilesystemLock.deferUntilLocked.<locals>.<lambda>Y
s���k�.�BR�6S�rDc����j�rF�j�!�jj�d�_d�_�j	d�y��Q�j�Ett
d�j�fz��}�jj��|��_�jj�j���_y)Nz&Timed out acquiring lock: %s after %fs)rGr=r�r<rVr5rKrCrBr��	_interval)rHrI�_tryLockrYr�rzs �����rErMz9DeferredFilesystemLock.deferUntilLocked.<locals>._tryLock[
s�����y�y�{��$�$�0��%�%�,�,�.�(,�D�%�$(��!��
�
�4� ��&�4�+<�+<�+D�$�$�D�#�y�y�'�2�3���F�)-���(A�(A���f�)�D�%�%)�O�O�$=�$=�d�n�n�h�$W��!rD)rHzUnion[Failure, Exception]r�r�r�)r<r]r9rU)r�rzrIrMrYs``@@@rE�deferUntilLockedz'DeferredFilesystemLock.deferUntilLocked2
sS������(��(�E���
�	"�&%�%S�T��	X�	X�.	�
��rDre)rCr�rDzOptional[IReactorTime]r�r�)rzzOptional[float]r�zDeferred[None])
r?r@rArBrLr<r�r=r�rNrCrDrEr;r;
s/����I�+/�L�(�/�+/�L�(�/�$�BrDr;)rUrmrZr]rwrvr=rKr�rhrVr�r�r�r�rrr+r;r9rH)rRr5r�r5)rXr7r�rQre)rXrOr�rJ)r`rrarGrbrHr�rQ)rgr	rarGrbrHr�rQ)rgr
rarGrbrHr�rQ)rgrrarGrbrHr�rQ)rgrrarGrbrHr�rQ)ryz'Deferred[object]'r�r�)r}r7r�r7)r}r5r�r5)r�r�r�r�)r�r�)r�r7rzrMr�r7)rEzYUnion[Coroutine[Deferred[Any], Any, _T], Generator[Deferred[Any], Any, _T], Deferred[_T]]r�r�)FF)
rer}rfz
Literal[True]rgr�rhr�r�z2Deferred[_DeferredListSingleResultT[_SelfResultT]]r|)
rer}rfzLiteral[False]rgr�rhr�r�z0Deferred[_DeferredListResultListT[_SelfResultT]])
rer}rfr�rgr�rhr�r�zkUnion[Deferred[_DeferredListSingleResultT[_SelfResultT]], Deferred[_DeferredListResultListT[_SelfResultT]]])F)rsz"List[_DeferredListResultItemT[_T]]rgr�r�zList[_T])rezIterable[Deferred[_T]]rhr�r�zDeferred[List[_T]])r�zSequence[Deferred[_T]]r�zDeferred[tuple[int, _T]])r��_DeferableGeneratorryr>r�z
Deferred[Any])rgz"Callable[..., _DeferableGenerator]r�zCallable[..., Deferred[object]])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�)
rXr�r�rPr�rQr�rRr�r�)r�r�r�rQr�r�)rXr5r�rQr�r�)r�zQUnion[Generator[Deferred[Any], object, _T], Coroutine[Deferred[Any], object, _T]]r�r�)rgz/Callable[_P, Generator[Deferred[Any], Any, _T]]r�r	)�rB�
__future__rrBr�r��abcrr�asynciorrr�contextvarsr	rRr
r��enumr�	functoolsr
�sysrr�typesrrrr�typingrrrrrrrrrrrrr r!r"r#r$r%r&�attr�incrementalr'r(r)r*r+�twisted.internet.interfacesr,r-�twisted.loggerr.�twisted.pythonr/�twisted.python.compatr0r1r2�twisted.python.deprecater3r4�twisted.python.failurer5r6rPr7r8�versionr�rZr=rHrKr�rMrSrZr]rcrhrzr~r�r�r�r�r�r�r�r��DeferredCallback�DeferredErrbackrFr�r�rPr�r�r�r�r�rUrVrXrb�_DeferredListSingleResultTr��_DeferredListResultItemTryrirmr�r�r�r�rvrwr�rOr�r�r_r�r��sr�r�r�r�r�rDr�r�r�rrr%r)r+r9r@r;�__all__rCrDrE�<module>rks2��
�
#����#�:�:�J���(�O�O�������,��8�8�B�!�#�8�8�B�7��h��
�T�]���t�_���=�.�0�0�:�=�
�����Y���9�����
�
�(

� ���'.��:C����$
��!��*1��=F����
��
��6�������	�
��
���� '��3<����
��<!�O�<!��<!��<!��	<!�~��I�r�1�a� �<��B�	�B������(
��
�"�
!�
!�
����	�
�C��K�(���3��;�'��!�&�#�+�.��#�C��K�0���	�
���	�(;�(;� <�<�=�!�!�	#��

�
�o�/���9L�9L�1M�M�N�!�!�	#��	���+;�2�*>��'�>��~�&���~�&��'F�'F�TjA�y��&�jA�ZS��S��
S�8�(��(��(�V#�<��#4�5�� ��|�!3�4��� 8�� F�G����"'�#�	�6��(�����	�

<�����-2�!&�#�	�6��)�����	�

:����#(�!&�#�		�6�	��	��	��		�

�	�!�L�MQ��
%�c�
*�+�MQ�bNS�&�2�&�FJ�&�
�&�AF�,�(�,�9=�,��,�:!�9�!�L�`��
����: ���d� 2�3��=��=�&6�=��=�@�G�I�r�1�a�(�*R�S�?�)�?�$�?�T�?�J�]��

� ����T��7�'�,�/�7��7�2�
�2�
�2�
�2�
$�2��2�
�2�6
�]��]�
�]�
$�
]��]�
�]�
�]�@
9��
9�5�
9�	�
9� ���4����2�
��
��.�Y��N�6�N��N�hW
�C�W
�t8�(�8�vF�-�F�R	�I�	�	�Y�	�E#�G�B�K�E#�P�y��c�X�4�4�c�L�rD

Zerion Mini Shell 1.0