Hacked By AnonymousFox

Current Path : /proc/thread-self/root/proc/self/root/opt/alt/python311/lib64/python3.11/asyncio/__pycache__/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/opt/alt/python311/lib64/python3.11/asyncio/__pycache__/futures.cpython-311.pyc

�

c��f�7��8�dZdZddlZddlZddlZddlZddlmZddl	m
Z
ddl	mZddl	mZdd	l	m
Z
e
jZe
jZe
jZe
jZejdz
ZGd
�d��ZeZd�Zd
�Zd�Zd�Zd�Zd�Zdd�d�Z	ddlZejxZZdS#e$rYdSwxYw)z.A Future class similar to the one in PEP 3148.)�Future�wrap_future�isfuture�N)�GenericAlias�)�base_futures)�events)�
exceptions)�format_helpersc���eZdZdZeZdZdZdZdZ	dZ
dZdZdZ
dd�d�Zd�Zd�Zee��Zed���Zejd	���Zd
�Zd�Zdd�Zd
�Zd�Zd�Zd�Zd�Zdd�d�Zd�Z d�Z!d�Z"d�Z#e#Z$dS)ra,This class is *almost* compatible with concurrent.futures.Future.

    Differences:

    - This class is not thread-safe.

    - result() and exception() do not take a timeout argument and
      raise an exception when the future isn't done yet.

    - Callbacks registered with add_done_callback() are always called
      via the event loop's call_soon().

    - This class is not compatible with the wait() and as_completed()
      methods in the concurrent.futures package.

    (In Python 3.4 or later we may be able to unify the implementations.)
    NF��loopc���|�tj��|_n||_g|_|j���r-tjtjd����|_	dSdS)z�Initialize the future.

        The optional event_loop argument allows explicitly setting the event
        loop object used by the future. If it's not provided, the future uses
        the default event loop.
        Nr)
r	�_get_event_loop�_loop�
_callbacks�	get_debugr�
extract_stack�sys�	_getframe�_source_traceback��selfrs  �6/opt/alt/python311/lib64/python3.11/asyncio/futures.py�__init__zFuture.__init__Hsq���<��/�1�1�D�J�J��D�J�����:���!�!�	"�%3�%A��
�a� � �&"�&"�D�"�"�"�	"�	"�c�*�tj|��S�N)r�_future_repr�rs r�__repr__zFuture.__repr__Xs���(��.�.�.rc��|jsdS|j}|jj�d�||d�}|jr
|j|d<|j�|��dS)Nz exception was never retrieved)�message�	exception�future�source_traceback)�_Future__log_traceback�
_exception�	__class__�__name__rr�call_exception_handler)r�exc�contexts   r�__del__zFuture.__del__[sx���#�	�
�F��o���>�*�J�J�J���	
�
���!�	A�*.�*@�G�&�'��
�)�)�'�2�2�2�2�2rc��|jSr)r'r s r�_log_tracebackzFuture._log_tracebackms���#�#rc�6�|rtd���d|_dS)Nz'_log_traceback can only be set to FalseF)�
ValueErrorr')r�vals  rr0zFuture._log_tracebackqs(���	H��F�G�G�G�$����rc�6�|j}|�td���|S)z-Return the event loop the Future is bound to.Nz!Future object is not initialized.)r�RuntimeErrorrs  r�get_loopzFuture.get_loopws"���z���<��B�C�C�C��rc���|j�|j}d|_|S|j�tj��}ntj|j��}|j|_d|_|S)z�Create the CancelledError to raise if the Future is cancelled.

        This should only be called once when handling a cancellation since
        it erases the saved context exception value.
        N)�_cancelled_exc�_cancel_messager
�CancelledError�__context__�rr,s  r�_make_cancelled_errorzFuture._make_cancelled_error~se����*��%�C�"&�D���J���'��+�-�-�C�C��+�D�,@�A�A�C��-���"����
rc��d|_|jtkrdSt|_||_|���dS)z�Cancel the future and schedule callbacks.

        If the future is already done or cancelled, return False.  Otherwise,
        change the future's state to cancelled, schedule the callbacks and
        return True.
        FT)r'�_state�_PENDING�
_CANCELLEDr9�_Future__schedule_callbacks)r�msgs  r�cancelz
Future.cancel�sD�� %����;�(�"�"��5� ���"����!�!�#�#�#��trc��|jdd�}|sdSg|jdd�<|D]"\}}|j�|||����#dS)z�Internal: Ask the event loop to call all callbacks.

        The callbacks are scheduled to be called as soon as possible. Also
        clears the callback list.
        N�r-)rr�	call_soon)r�	callbacks�callback�ctxs    r�__schedule_callbackszFuture.__schedule_callbacks�sn���O�A�A�A�&�	��	��F��������&�	>�	>�M�H�c��J� � ��4�� �=�=�=�=�	>�	>rc�"�|jtkS)z(Return True if the future was cancelled.)r?rAr s r�	cancelledzFuture.cancelled�s���{�j�(�(rc�"�|jtkS)z�Return True if the future is done.

        Done means either that a result / exception are available, or that the
        future was cancelled.
        )r?r@r s r�donezFuture.done�s���{�h�&�&rc��|jtkr|���}|�|jtkrt	jd���d|_|j�|j�|j	���|j
S)aReturn the result this future represents.

        If the future has been cancelled, raises CancelledError.  If the
        future's result isn't yet available, raises InvalidStateError.  If
        the future is done and has an exception set, this exception is raised.
        zResult is not ready.F)r?rAr=�	_FINISHEDr
�InvalidStateErrorr'r(�with_traceback�
_exception_tb�_resultr<s  r�resultz
Future.result�sw���;�*�$�$��,�,�.�.�C��I��;�)�#�#��.�/E�F�F�F�$����?�&��/�0�0��1C�D�D�D��|�rc��|jtkr|���}|�|jtkrt	jd���d|_|jS)a&Return the exception that was set on this future.

        The exception (or None if no exception was set) is returned only if
        the future is done.  If the future has been cancelled, raises
        CancelledError.  If the future isn't done yet, raises
        InvalidStateError.
        zException is not set.F)r?rAr=rQr
rRr'r(r<s  rr$zFuture.exception�sV���;�*�$�$��,�,�.�.�C��I��;�)�#�#��.�/F�G�G�G�$�����rrFc���|jtkr|j�|||���dS|�t	j��}|j�||f��dS)z�Add a callback to be run when the future becomes done.

        The callback is called with a single argument - the future object. If
        the future is already done when this is called, the callback is
        scheduled with call_soon.
        rFN)r?r@rrG�contextvars�copy_contextr�append)r�fnr-s   r�add_done_callbackzFuture.add_done_callback�sg���;�(�"�"��J� � ��T�7� �;�;�;�;�;���%�2�4�4���O�"�"�B��=�1�1�1�1�1rc����fd�|jD��}t|j��t|��z
}|r||jdd�<|S)z}Remove all instances of a callback from the "call when done" list.

        Returns the number of callbacks removed.
        c�*��g|]\}}|�k�||f��S�r`)�.0�frJr\s   �r�
<listcomp>z/Future.remove_done_callback.<locals>.<listcomp>�s2���*�*�*�"*�1�c�!"�b��� !�#�h�!(��rN)r�len)rr\�filtered_callbacks�
removed_counts `  r�remove_done_callbackzFuture.remove_done_callback�sk���
*�*�*�*�.2�o�*�*�*���D�O�,�,�s�3E�/F�/F�F�
��	4�!3�D�O�A�A�A���rc��|jtkrtj|j�d|�����||_t
|_|���dS)z�Mark the future done and set its result.

        If the future is already done when this method is called, raises
        InvalidStateError.
        �: N)r?r@r
rRrUrQrB)rrVs  r�
set_resultzFuture.set_result�sX���;�(�"�"��.�$�+�/I�/I��/I�/I�J�J�J��������!�!�#�#�#�#�#rc�^�|jtkrtj|j�d|�����t	|t
��r
|��}t|��turtd���||_|j	|_
t|_|���d|_
dS)z�Mark the future done and set an exception.

        If the future is already done when this method is called, raises
        InvalidStateError.
        rizPStopIteration interacts badly with generators and cannot be raised into a FutureTN)r?r@r
rR�
isinstance�type�
StopIteration�	TypeErrorr(�
__traceback__rTrQrBr')rr$s  r�
set_exceptionzFuture.set_exception	s����;�(�"�"��.�$�+�/I�/I��/I�/I�J�J�J��i��&�&�	$�!�	���I��	�?�?�m�+�+��A�B�B�
B�#���&�4�������!�!�#�#�#�#����rc#�K�|���sd|_|V�|���std���|���S)NTzawait wasn't used with future)rO�_asyncio_future_blockingr5rVr s r�	__await__zFuture.__await__sU�����y�y�{�{�	�,0�D�)��J�J�J��y�y�{�{�	@��>�?�?�?��{�{�}�}�rr)%r*�
__module__�__qualname__�__doc__r@r?rUr(rrr9r8rsr'rr!r.�classmethodr�__class_getitem__�propertyr0�setterr6r=rDrBrMrOrVr$r]rgrjrqrt�__iter__r`rrrrs���������&�F��G��J��E����O��N� %���O�#�"�"�"�"�"� /�/�/�3�3�3� $��L�1�1��
�$�$��X�$���%�%���%�
������(
�
�
�
�>�>�>�)�)�)�'�'�'����"��� 04�2�2�2�2�2� ���
$�
$�
$�$�$�$�&����H�H�Hrrc�T�	|j}|��S#t$rYnwxYw|jSr)r6�AttributeErrorr)�futr6s  r�	_get_loopr�+sH����<���x�z�z����
�
�
���
�����9�s��
 � c�\�|���rdS|�|��dS)z?Helper setting the result only if the future was not cancelled.N)rMrj)rrVs  r�_set_result_unless_cancelledr�7s/��
�}�}�������N�N�6�����rc��t|��}|tjjurt	j|j�S|tjjurt	j|j�S|tjjurt	j|j�S|Sr)rm�
concurrent�futuresr:r
�args�TimeoutErrorrR)r,�	exc_classs  r�_convert_future_excr�>su���S�	�	�I��J�&�5�5�5��(�#�(�3�3�	�j�(�5�	5�	5��&���1�1�	�j�(�:�	:�	:��+�S�X�6�6��
rc�L�|���sJ�|���r|j��|j��sdS|���}|�|jt
|����dS|���}|j|��dS)z8Copy state from a future to a concurrent.futures.Future.N)	rOrMrD�set_running_or_notify_cancelr$rqr�rVrj)r��sourcer$rVs    r�_set_concurrent_future_stater�Js����;�;�=�=���=�
�������
�����2�:�2�4�4����� � �"�"�I��� �
� �!4�Y�!?�!?�@�@�@�@�@��������
��f�%�%�%�%�%rc��|���sJ�|���rdS|���rJ�|���r|���dS|���}|�$|�t|����dS|���}|�|��dS)zqInternal helper to copy state from another Future.

    The other Future may be a concurrent.futures.Future.
    N)rOrMrDr$rqr�rVrj)r��destr$rVs    r�_copy_future_stater�Ys���
�;�;�=�=���=��~�~�������y�y�{�{���?�
�����$����
�
�
�
�
��$�$�&�&�	�� ����2�9�=�=�>�>�>�>�>��]�]�_�_�F��O�O�F�#�#�#�#�#rc�������t���s.t�tjj��std���t���s.t�tjj��std���t���rt
���nd�t���rt
���nd�d�����fd�}����fd�}��|����|��dS)aChain two futures so that when one completes, so does the other.

    The result (or exception) of source will be copied to destination.
    If destination is cancelled, source gets cancelled too.
    Compatible with both asyncio.Future and concurrent.futures.Future.
    z(A future is required for source argumentz-A future is required for destination argumentNc�h�t|��rt||��dSt||��dSr)rr�r�)r%�others  r�
_set_statez!_chain_future.<locals>._set_state}s>���F���	8��u�f�-�-�-�-�-�(���7�7�7�7�7rc���|���r8����ur����dS���j��dSdSr)rMrD�call_soon_threadsafe)�destination�	dest_loopr��source_loops ���r�_call_check_cancelz)_chain_future.<locals>._call_check_cancel�sa���� � �"�"�	@��"�k�Y�&>�&>��
�
�������0�0���?�?�?�?�?�		@�	@rc��������r������rdS����ur��|��dS����rdS����|��dSr)rM�	is_closedr�)r�r�r�r�r�s ����r�_call_set_statez&_chain_future.<locals>._call_set_state�s�����!�!�#�#�	��%�)�*=�*=�*?�*?�%��F���	�[� 8� 8��J�{�F�+�+�+�+�+��"�"�$�$�
����*�*�:�{�F�K�K�K�K�Kr)rrlr�r�rror�r])r�r�r�r�r�r�r�s``  @@@r�
_chain_futurer�ms_��������F���D�J�v�/9�/A�/H�%J�%J�D��B�C�C�C��K� � �I��K�4>�4F�4M�*O�*O�I��G�H�H�H�'/��'7�'7�A�)�F�#�#�#�T�K�*2�;�*?�*?�I�	�+�&�&�&�T�I�8�8�8�@�@�@�@�@�@�@�	L�	L�	L�	L�	L�	L�	L�	L��!�!�"4�5�5�5�
���_�-�-�-�-�-rr
c���t|��r|St|tjj��s
Jd|�����|�tj��}|���}t||��|S)z&Wrap concurrent.futures.Future object.z+concurrent.futures.Future is expected, got )	rrlr�r�rr	r�
create_futurer�)r%r�
new_futures   rrr�s���������
��f�j�0�7�8�8�A�A�@�f�@�@�A�A�8��|��%�'�'���#�#�%�%�J��&�*�%�%�%��r) rw�__all__�concurrent.futuresr�rY�loggingr�typesr�rr	r
rrr@rArQ�DEBUG�STACK_DEBUGr�	_PyFuturer�r�r�r�r�r�r�_asyncio�_CFuture�ImportErrorr`rr�<module>r�s���4�4���������������
�
�
�
�������������������������������� ��� ��
�
$�
��"�	��m�a���F�F�F�F�F�F�F�F�T
�	�	�	�	����	�	�	�&�&�&�$�$�$�().�).�).�X!%�
�
�
�
�
�(��O�O�O�
!��'�F�X�X�X��	�	�	�	��D�D�	���s�B�B�B

Hacked By AnonymousFox1.0, Coded By AnonymousFox