← back to Atmos Game

assets/gen/.venv/lib/python3.12/site-packages/anyio/_core/__pycache__/_tasks.cpython-312.pyc

207 lines

�

c�bjF3���ddlmZddlZddlZddlmZmZddlmZddl	m
Z
mZddlm
Z
ddlmZddlmZmZmZd	d
lmZmZddlmZmZdd
lmZmZmZej<dk\rddlmZnddl mZej<dk\r	ddlm!Z!m"Z"nddl m!Z!m"Z"ed�Z#edd��Z$edde!��Z%e"d�Z&Gd�dee'�Z(e(�Z)Gd�d�Z*e	d#					d$d��Z+d#d%d�Z,d&d�Z-d'd �Z.eGd!�d"ee$e%f��Z/y)(�)�annotationsN)�	Coroutine�	Generator)�contextmanager)�Enum�auto)�iscoroutine)�
TracebackType)�Any�Generic�final�)�	TaskGroup�
TaskStatus�)�get_async_backend�get_cancelled_exc_class)�
TaskCancelled�
TaskFailed�TaskNotFinished)��
)�TypeVar)r�)�Never�TypeVarTuple�T�T_coT)�	covariant�
T_startval)r�default�PosArgsTc��eZdZddd�Zy)�_IgnoredTaskStatusNc��y�N���self�values  �i/Users/macstudio3/Projects/atmos-game/assets/gen/.venv/lib/python3.12/site-packages/anyio/_core/_tasks.py�startedz_IgnoredTaskStatus.started&s���r&)r*�object�return�None)�__name__�
__module__�__qualname__r,r'r-r+r$r$%s��
r-r$c��eZdZdZdZejdd�					dd�Zddd�Ze	dd��Z
e
jdd	��Z
e	dd
��Ze	dd��Z
e	dd��Zejdd
��Zdd�Z								dd�Zy)�CancelScopea`
    Wraps a unit of work that can be made separately cancellable.

    :param deadline: The time (clock value) when this scope is cancelled automatically
    :param shield: ``True`` to shield the cancel scope from external cancellation
    :raises NoEventLoopError: if no supported asynchronous event loop is running in the
        current thread
    )�__weakref__F��deadline�shieldc�8�t�j||��S)N)r9r8)r�create_cancel_scope)�clsr8r9s   r+�__new__zCancelScope.__new__9s��!�"�6�6�f�x�6�X�Xr-Nc��t�)z~
        Cancel this scope immediately.

        :param reason: a message describing the reason for the cancellation

        ��NotImplementedError)r)�reasons  r+�cancelzCancelScope.cancel>s
��"�!r-c��t�)z�
        The time (clock value) when this scope is cancelled automatically.

        Will be ``float('inf')`` if no timeout has been set.

        r?�r)s r+r8zCancelScope.deadlineG�
��"�!r-c��t�r&r?r(s  r+r8zCancelScope.deadlineQ���!�!r-c��t�)z+``True`` if :meth:`cancel` has been called.r?rDs r+�
cancel_calledzCancelScope.cancel_calledUs
��"�!r-c��t�)a
        ``True`` if this scope suppressed a cancellation exception it itself raised.

        This is typically used to check if any work was interrupted, or to see if the
        scope was cancelled due to its deadline being reached. The value will, however,
        only be ``True`` if the cancellation was triggered by the scope itself (and not
        an outer scope).

        r?rDs r+�cancelled_caughtzCancelScope.cancelled_caughtZs
��"�!r-c��t�)z�
        ``True`` if this scope is shielded from external cancellation.

        While a scope is shielded, it will not receive cancellations from outside.

        r?rDs r+r9zCancelScope.shieldgrEr-c��t�r&r?r(s  r+r9zCancelScope.shieldqrGr-c��t�r&r?rDs r+�	__enter__zCancelScope.__enter__us��!�!r-c��t�r&r?)r)�exc_type�exc_val�exc_tbs    r+�__exit__zCancelScope.__exit__xs
��"�!r-)r8�floatr9�boolr/r5r&)rAz
str | Noner/r0�r/rU)r*rUr/r0)r/rV)r*rVr/r0)r/r5)rQztype[BaseException] | NonerR�BaseException | NonerSzTracebackType | Noner/rV)r1r2r3�__doc__�	__slots__�math�infr=rB�propertyr8�setterrIrKr9rOrTr'r-r+r5r5-s����!�I�#'�(�(�5�Y��Y�48�Y�	�Y�
"��"��"��_�_�"��"��"��"��
"��
"��"��"��]�]�"��"�"�"�,�"�&�"�%�	"�

�"r-r5c#�"K�t�j}|�
|�|zntj}t�j	||��5}|��ddd�j
r|�|jk\rt�yy#1swY�1xYw�w)a,
    Create a context manager which raises a :class:`TimeoutError` if does not finish in
    time.

    :param delay: maximum allowed time (in seconds) before raising the exception, or
        ``None`` to disable the timeout
    :param shield: ``True`` to shield the cancel scope from external cancellation
    :return: a context manager that yields a cancel scope
    :rtype: :class:`~typing.ContextManager`\[:class:`~anyio.CancelScope`\]
    :raises NoEventLoopError: if no supported asynchronous event loop is running in the
        current thread

    Nr7)r�current_timer[r\r;rKr8�TimeoutError)�delayr9r`r8�cancel_scopes     r+�
fail_afterrd�s�����"%�&�3�3�L�+0�+<����&�$�(�(�H�	�	�	0�	0��&�
1�
�	���
�
�$�$���<�;P�;P�)P���*Q�$�
�
�s�AB�B�0B�B�Bc��|�t�j�|zntj}t�j	||��S)a�
    Create a cancel scope with a deadline that expires after the given delay.

    :param delay: maximum allowed time (in seconds) before exiting the context block, or
        ``None`` to disable the timeout
    :param shield: ``True`` to shield the cancel scope from external cancellation
    :return: a cancel scope
    :raises NoEventLoopError: if no supported asynchronous event loop is running in the
        current thread

    r7)rr`r[r\r;)rbr9r8s   r+�
move_on_afterrf�sD��9>�8I�	�	�	)�	)�	+�e�	3�t�x�x�
���2�2�H�V�2�T�Tr-c�2�t�j�S)a�
    Return the nearest deadline among all the cancel scopes effective for the current
    task.

    :return: a clock value from the event loop's internal clock (or ``float('inf')`` if
        there is no deadline in effect, or ``float('-inf')`` if the current scope has
        been cancelled)
    :rtype: float
    :raises NoEventLoopError: if no supported asynchronous event loop is running in the
        current thread

    )r�current_effective_deadliner'r-r+rhrh�s����9�9�;�;r-c�2�t�j�S)z�
    Create a task group.

    :return: a task group
    :raises NoEventLoopError: if no supported asynchronous event loop is running in the
        current thread

    )r�create_task_groupr'r-r+rjrj�s����0�0�2�2r-c���eZdZUdZGd�de�ZdZded<ded<dd	�Zdd
�Z	dd�Z
edd��Zedd
��Z
edd��Zedd��Zedd��Zedd��Zdd�Zdd�Zdd�Zy)�
TaskHandlea\
    Returned from the task-spawning methods of :class:`TaskGroup`. Can be awaited on to
    get the return value of the task (or the raised exception). If the task was
    terminated by a :exc:`BaseException`, :exc:`TaskFailed` will be raised (or its
    subclass :exc:`TaskCancelled` if the task was cancelled).

    .. versionadded:: 4.14.0
    c�V�eZdZdZe�Ze�Ze�Ze�Ze�Z	y)�TaskHandle.Statusa�
        The status of a task handle.

        .. attribute:: PENDING

            The task has not finished yet.
        .. attribute:: FINISHED

            The task has finished with a return value.
        .. attribute:: CANCELLING

            The task has been cancelled but has not finished yet.
        .. attribute:: CANCELLED

            The task was cancelled and has finished since.
        .. attribute:: FAILED

            The task raised an exception.
        N)
r1r2r3rYr�PENDING�FINISHED�
CANCELLING�	CANCELLED�FAILEDr'r-r+�Statusrn�s,��	�(�&���6���V�
��F�	���r-rt)r6�_coro�_name�
_cancel_scope�_finished_event�
_return_value�_start_value�
_exceptionrryr rzc���ddlm}||_t�|_|�|_d|_|�t|�|_yt|�r|j|_yt|�|_y)Nr)�Event)�_synchronizationr}rur5rwrxr{�strrvr	r3)r)�coro�namer}s    r+�__init__zTaskHandle.__init__�sX��+���
�(�]���$�w���04������T��D�J�
��
��*�*�D�J��T��D�Jr-c��:K�d}|j5	|j�d{���}||_	|j
j
�~	ddd�y7�1#t$r
}||_�d}~wwxYw#|j
j
�~wxYw#1swYyxYw�w)NT)rwrury�
BaseExceptionr{rx�set)r)�__tracebackhide__�retval�excs    r+�	_run_corozTaskHandle._run_coros����� ��
�
�
�	
�#�z�z�)��
&,��"��$�$�(�(�*�� �
�)�� �
�"%�����
���$�$�(�(�*��� �
�s_�B�B�A�A�A�A/�B�	B�A�	A,�A'�'A,�,A/�/B�B�B�Bc�n�|jj�s|jj�yy)aF
        Set the task to a cancelled state.

        This will interrupt any interruptible asynchronous operation, and will cause
        any further awaits on this task to get immediately cancelled, unless done in
        a shielded cancel scope.

        If the task has already finished, this method has no effect.
        N)rx�is_setrwrBrDs r+rBzTaskHandle.cancels-���#�#�*�*�,����%�%�'�-r-c��|jS)zy
        The coroutine object that was passed to one of the task-spawning methods in
        :class:`TaskGroup`.
        )rurDs r+r�zTaskHandle.coro*s���z�z�r-c��|jj�sJ|jjrtj
jStj
jS|j�Rt|jt��rtj
jStj
jStj
jS)a=
        The current status of the task.

        Every task starts in the :attr:`~TaskHandle.Status.PENDING` state.
        If a task is cancelled while in this state, it will transition to the
        :attr:`~TaskHandle.Status.CANCELLING` state. When the task finishes, it will
        transition to one of the three final states (
        :attr:`~TaskHandle.Status.FINISHED`, :attr:`~TaskHandle.Status.FAILED`, or
        :attr:`~TaskHandle.Status.CANCELLING`) depending on the exception the task
        raised, if any. No other status transitions will happen.
        )rxr�rwrIrlrtrqror{�
isinstancerrrrsrprDs r+�statuszTaskHandle.status2s����#�#�*�*�,��!�!�/�/�!�(�(�3�3�3�!�(�(�0�0�0�
�_�_�
(��$�/�/�+B�+D�E�!�(�(�2�2�2�!�(�(�/�/�/��$�$�-�-�-r-c��|jS)zThe name of the task.)rvrDs r+r�zTaskHandle.nameLs���z�z�r-c��|jxtjjk(rt	d��xtjj
k(ryxtjjk(rtd��xtjjk(rtd�|j�tjjk(r|jSy)z�
        The exception raised by the task, or ``None`` if it finished without raising.

        :raises TaskNotFinished: if the task has not finished yet
        :raises TaskCancelled: if the task was cancelled

        �the task has not finished yetN�the task was cancelled)r�rlrtrorrprqrrrr{rsrDs r+�	exceptionzTaskHandle.exceptionQs����k�k�*��"�"�*�*�%�&E�F�F�+��"�"�+�+��-��"�"�-�-�#�$<�=�=�,��"�"�,�,�#�$<�=�4�?�?�R��"�"�)�)����&�*r-c���|jxtjjk(rt	d��xtjj
k(r
|jSxtjjk(rtd��xtjjk(rtd�|j�tjjk(rtd�|j�y)z�
        The return value of the task.

        :raises TaskNotFinished: if the task has not finished yet
        :raises TaskCancelled: if the task was cancelled
        :raises TaskFailed: if the task raised an exception

        r�r�zthe task raised an exceptionN)
r�rlrtrorrpryrqrrrr{rsrrDs r+�return_valuezTaskHandle.return_valuefs����k�k�*��"�"�*�*�%�&E�F�F�+��"�"�+�+��)�)�)�-��"�"�-�-�#�$<�=�=�,��"�"�,�,�#�$<�=�4�?�?�R��"�"�)�)� �!?�@�d�o�o�U�*r-c�N�	|jS#t$r
td�d�wxYw)z�
        The value passed to :meth:`task_status.started() <.abc.TaskStatus.started>`,

        :raises RuntimeError: if the task was not started with :meth:`TaskGroup.start()
            <.abc.TaskGroup.start>`
        z/the task was not started with TaskGroup.start()N)rz�AttributeError�RuntimeErrorrDs r+�start_valuezTaskHandle.start_value|s5��	��$�$�$���	��A���
�	�s��$c��TK�|jj��d{���y7��w)z�
        Wait for the task to finish.

        This method will return as soon as the task has finished, no matter how it
        happened.
        N)rx�waitrDs r+r�zTaskHandle.wait�s �����"�"�'�'�)�)�)�s�(�&�(c#�K�|jj�j�Ed{���|jS7��wr&)rxr��	__await__r�rDs r+r�zTaskHandle.__await__�s8�����'�'�,�,�.�8�8�:�:�:�� � � �	;�s�,A�?�Ac	��d|jj�d|jjj	��d|j
�d|j�d�	S)N�<� z name=z coro=�>)�	__class__r1r�r��lowerrvrurDs r+�__repr__zTaskHandle.__repr__�sS������'�'�(��$�+�+�*:�*:�*@�*@�*B�)C�D��J�J�>���
�
�~�Q�
8�	
r-N)r��Coroutine[Any, Any, T_co]r�r.r/r0)r/r0)r/r�)r/rn)r/r)r/rX)r/r)r/r )r/zGenerator[Any, Any, T_co])r1r2r3rYrrtrZ�__annotations__r�r�rBr]r�r�r�r�r�r�r�r�r�r'r-r+rlrl�s�������6	�I�����
#�
�(������.��.�2�����'��'�(�V��V�*����*�!�
r-rl)F)rb�float | Noner9rVr/z"Generator[CancelScope, None, None])rbr�r9rVr/r5rW)r/r)0�
__future__rr[�sys�collections.abcrr�
contextlibr�enumrr�inspectr	�typesr
�typingrrr
�abcrr�
_eventlooprr�_exceptionsrrr�version_infor�typing_extensionsrrrrr r"r.r$�TASK_STATUS_IGNOREDr5rdrfrhrjrlr'r-r+�<module>r�s��"��
������&�&�'�B�C�C����w���)����w��*�*�5��C�L���v��&��
�\�T�5�
A�
��
�#��
��F�+�
�
)�*��Q"�Q"�h�(-����!%��'����6U�$
<� 	3��P
���z�)�*�P
��P
r-