%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.12/asyncio/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.12/asyncio/__pycache__/futures.cpython-312.pyc

�

���f�7��j�dZdZddlZddlZddlZddlZddlmZddl	m
Z
ddl	mZddl	mZdd	l	m
Z
e
jZe
jZe
j Ze
j"Zej$dz
ZGd
�d�ZeZd�Zd
�Zd�Zd�Zd�Zd�Zdd�d�Z	ddlZej(xZZy#e$rYywxYw)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��Zej,d	��Zd
�Zd�Zdd�Zd
�Zd�Zd�Zd�Zd�Zdd�d�Zd�Z d�Z!d�Z"d�Z#e#Z$y)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|_|jj	�r.tjtjd��|_	yy)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  �&/usr/lib/python3.12/asyncio/futures.py�__init__zFuture.__init__Hs[���<��.�.�0�D�J��D�J�����:�:���!�%3�%A�%A��
�
�a� �&"�D�"�"�c�,�tj|�S�N)r�_future_repr�rs r�__repr__zFuture.__repr__Xs���(�(��.�.rc���|jsy|j}|jj�d�||d�}|jr|j|d<|j
j
|�y)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__[sl���#�#�
��o�o���>�>�*�*�+�+I�J���	
���!�!�*.�*@�*@�G�&�'��
�
�)�)�'�2rc��|jSr)r'r s r�_log_tracebackzFuture._log_tracebackms���#�#�#rc�,�|rtd��d|_y)Nz'_log_traceback can only be set to FalseF)�
ValueErrorr')r�vals  rr0zFuture._log_tracebackqs����F�G�G�$��rc�8�|j}|�td��|S)z-Return the event loop the Future is bound to.z!Future object is not initialized.)r�RuntimeErrorrs  r�get_loopzFuture.get_loopws!���z�z���<��B�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~sr�����*��%�%�C�"&�D���J����'��+�+�-�C��+�+�D�,@�,@�A�C��-�-���"����
rc�~�d|_|jtk7ryt|_||_|j�y)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�s9�� %����;�;�(�"�� ���"����!�!�#�rc��|jdd}|syg|jdd|D]#\}}|jj|||���%y)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�sR���O�O�A�&�	���������&�	>�M�H�c��J�J� � ��4�� �=�	>rc�(�|jtk(S)z(Return True if the future was cancelled.)r?rAr s r�	cancelledzFuture.cancelled�s���{�{�j�(�(rc�(�|jtk7S)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�$�|jtk(r|j�}|�|jtk7rt	j
d��d|_|j�%|jj|j��|jS)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�sx���;�;�*�$��,�,�.�C��I��;�;�)�#��.�.�/E�F�F�$����?�?�&��/�/�0�0��1C�1C�D�D��|�|�rc���|jtk(r|j�}|�|jtk7rt	j
d��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�sS���;�;�*�$��,�,�.�C��I��;�;�)�#��.�.�/F�G�G�$������rrFc���|jtk7r|jj|||��y|�t	j
�}|jj||f�y)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�sR���;�;�(�"��J�J� � ��T�7� �;���%�2�2�4���O�O�"�"�B��=�1rc��|jD��cgc]\}}||k7r||f��}}}t|j�t|�z
}|r||jdd|Scc}}w)z}Remove all instances of a callback from the "call when done" list.

        Returns the number of callbacks removed.
        N)r�len)rr\�frJ�filtered_callbacks�
removed_counts      r�remove_done_callbackzFuture.remove_done_callback�sl��/3�o�o�*�"*�1�c�!"�b�� !�#�h�*��*��D�O�O�,�s�3E�/F�F�
��!3�D�O�O�A�����
*s�Ac��|jtk7r$tj|j�d|����||_t
|_|j
�y)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�sJ���;�;�(�"��.�.�$�+�+��b���/I�J�J��������!�!�#rc�L�|jtk7r$tj|j�d|����t	|t
�r|�}t|�turtd��||_|j|_
t|_|j�d|_
y)z�Mark the future done and set an exception.

        If the future is already done when this method is called, raises
        InvalidStateError.
        rezPStopIteration 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����;�;�(�"��.�.�$�+�+��b���/I�J�J��i��&�!��I��	�?�m�+��A�B�
B�#���&�4�4�������!�!�#�#��rc#�K�|j�sd|_|��|j�std��|j�S�w)NTzawait wasn't used with future)rO�_asyncio_future_blockingr5rVr s r�	__await__zFuture.__await__s=�����y�y�{�,0�D�)��J��y�y�{��>�?�?��{�{�}��s�AA	r)%r*�
__module__�__qualname__�__doc__r@r?rUr(rrr9r8ror'rr!r.�classmethodr�__class_getitem__�propertyr0�setterr6r=rDrBrMrOrVr$r]rcrfrmrp�__iter__�rrrrs����&�F��G��J��E����O��N� %���O�#�"� /�3� $�L�1��
�$��$����%��%�
��(
�>�)�'��"� 04�2� �
$�$�&��Hrrc�^�	|j}|�S#t$rY|jSwxYwr)r6�AttributeErrorr)�futr6s  r�	_get_loopr}+s:����<�<���z����
���9�9��	
�s��	,�,c�H�|j�ry|j|�y)z?Helper setting the result only if the future was not cancelled.N)rMrf)r|rVs  r�_set_result_unless_cancelledr7s��
�}�}����N�N�6�rc�l�t|�}|tjjurt	j|j
�S|tjjurt	j|j
�S|tjjurt	j|j
�S|Sr)ri�
concurrent�futuresr:r
�args�TimeoutErrorrR)r,�	exc_classs  r�_convert_future_excr�>s����S�	�I��J�&�&�5�5�5��(�(�#�(�(�3�3�	�j�(�(�5�5�	5��&�&����1�1�	�j�(�(�:�:�	:��+�+�S�X�X�6�6��
rc�.�|j�sJ�|j�r|j�|j�sy|j	�}|�|j
t
|��y|j�}|j|�y)z8Copy state from a future to a concurrent.futures.Future.N)	rOrMrD�set_running_or_notify_cancelr$rmr�rVrf)r��sourcer$rVs    r�_set_concurrent_future_stater�Js����;�;�=��=�
�����
����2�:�2�2�4��� � �"�I��� �
� � �!4�Y�!?�@�������
���f�%rc�L�|j�sJ�|j�ry|j�rJ�|j�r|j�y|j�}|�|j	t|��y|j
�}|j|�y)zqInternal helper to copy state from another Future.

    The other Future may be a concurrent.futures.Future.
    N)rOrMrDr$rmr�rVrf)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�}�j|��j|�y)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�L�t|�r
t||�yt||�yr)rr�r�)r%�others  r�
_set_statez!_chain_future.<locals>._set_state}s���F���u�f�-�(���7rc���|j�r3����ur�j�y�j�j�yyr)rMrD�call_soon_threadsafe)�destination�	dest_loopr��source_loops ���r�_call_check_cancelz)_chain_future.<locals>._call_check_cancel�s<���� � �"��"�k�Y�&>��
�
���0�0����?�	#rc����j�r���j�ry����ur
��|�y�j�ry�j��|�yr)rM�	is_closedr�)r�r�r�r�r�s ����r�_call_set_statez&_chain_future.<locals>._call_set_state�s[����!�!�#��%�)�*=�*=�*?����	�[� 8��{�F�+��"�"�$���*�*�:�{�F�Kr)rrhr�r�rrkr}r])r�r�r�r�r�r�r�s``  @@@r�
_chain_futurer�ms�����F��J�v�/9�/A�/A�/H�/H�%J��B�C�C��K� ��K�4>�4F�4F�4M�4M�*O��G�H�H�'/��'7�)�F�#�T�K�*2�;�*?�	�+�&�T�I�8�@�	L��!�!�"4�5�
���_�-rr
c���t|�r|St|tjj�s
Jd|����|�tj�}|j�}t||�|S)z&Wrap concurrent.futures.Future object.z+concurrent.futures.Future is expected, got )	rrhr�r�rr	r�
create_futurer�)r%r�
new_futures   rrr�so������
��f�j�0�0�7�7�8�A�
5�f�Z�@�A�8��|��$�$�&���#�#�%�J��&�*�%��r) rs�__all__�concurrent.futuresr�rY�loggingr�typesr�rr	r
rrr@rArQ�DEBUG�STACK_DEBUGr�	_PyFuturer}rr�r�r�r�r�_asyncio�_CFuture�ImportErrorryrr�<module>r�s���4������
������� � ��� � ��
�
$�
$�
��"�"�	��m�m�a���F�F�T
�	�	��	�&�$�().�X!%�
�(��
!���'�F�X��	�	��	�s�B*�*B2�1B2

Zerion Mini Shell 1.0