HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/celery/__pycache__/result.cpython-310.pyc
o

-we��@stdZddlZddlZddlmZddlmZddlmZddl	m
Z
ddlmZddl
mZmZmZd	d
lmZmZd	dlmZmZd	dlmZd	d
lmZmZmZd	dlmZmZzddl Z Wne!ykdZ YnwdZ"dZ#dd�Z$edd��Z%edd��Z&Gdd�d�Z'ej(Gdd�de'��Z)ej(Gdd�de'��Z*ej(Gdd�de*��Z+ej(Gdd �d e)��Z,d#d!d"�Z-dS)$z3Task results/state and results for groups of tasks.�N)�deque)�contextmanager)�proxy)�isoparse)�cached_property)�Thenable�barrier�promise�)�current_app�states)�_set_task_join_will_block�task_join_will_block)�app_or_default)�ImproperlyConfigured�IncompleteStream�TimeoutError)�DependencyGraph�GraphFormatter)�
ResultBase�AsyncResult�	ResultSet�GroupResult�EagerResult�result_from_tuplez�Never call result.get() within a task!
See https://docs.celeryq.dev/en/latest/userguide/tasks.html#avoid-launching-synchronous-subtasks
cCst�rtt��dS�N)r�RuntimeError�E_WOULDBLOCK�rr�F/home/arjun/projects/env/lib/python3.10/site-packages/celery/result.py�assert_will_not_block$s�r cc�0�t�}td�z
dVWt|�dSt|�w�NF�rr
��reset_valuerrr�allow_join_result)��r&ccr!�NTr#r$rrr�denied_join_result3r'r)c@seZdZdZdZdS)rzBase class for results.N)�__name__�
__module__�__qualname__�__doc__�parentrrrrr=src@sBeZdZdZdZeZdZdZ			dhdd�Ze	dd��Z
e
jdd��Z
did	d
�Zdd�Z
d
d�Zdd�Zdd�Z		djdd�Z		djdd�Zdddddddddejejfdd�ZeZdd�Zdd�Zdkdd �Zd!d"�Zdkd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Z dld-d.�Z!e!Z"d/d0�Z#dmd1d2�Z$d3d4�Z%d5d6�Z&d7d8�Z'd9d:�Z(d;d<�Z)d=d>�Z*d?d@�Z+dAdB�Z,e-dCdD��Z.e	dEdF��Z/e	dGdH��Z0dIdJ�Z1dKdL�Z2dMdN�Z3dOdP�Z4e	dQdR��Z5e5Z6e	dSdT��Z7e	dUdV��Z8e8Z9e	dWdX��Z:e:jdYdX��Z:e	dZd[��Z;e	d\d]��Z<e	d^d_��Z=e	d`da��Z>e	dbdc��Z?e	ddde��Z@e	dfdg��ZAdS)nrzxQuery task state.

    Arguments:
        id (str): See :attr:`id`.
        backend (Backend): See :attr:`backend`.
    NcCsd|dur
tdt|�����t|p|j�|_||_|p|jj|_||_t|jdd�|_	d|_
d|_dS)Nz#AsyncResult requires valid id, not T��weakF)�
ValueError�typer�app�id�backendr.r	�
_on_fulfilled�on_ready�_cache�_ignored)�selfr4r5�	task_namer3r.rrr�__init__Xs�
zAsyncResult.__init__cCst|d�r|jSdS)z+If True, task result retrieval is disabled.r9F)�hasattrr9�r:rrr�ignoredfs
zAsyncResult.ignoredcCs
||_dS)z%Enable/disable task result retrieval.N)r9)r:�valuerrrr?ms
FcCs|jj||d�|j�||�S)Nr/)r5�add_pending_resultr7�then�r:�callback�on_errorr0rrrrBrszAsyncResult.thencCs|j�|�|Sr�r5�remove_pending_result�r:�resultrrrr6vszAsyncResult._on_fulfilledcCs|j}|j|o
|��fdfSr)r.r4�as_tuple)r:r.rrrrJzszAsyncResult.as_tuplecCs0g}|j}|�|j�|dur|�|���|S)zReturn as a list of task IDs.N)r.�appendr4�extend�as_list)r:�resultsr.rrrrM~szAsyncResult.as_listcCs(d|_|jr|j��|j�|j�dS)z/Forget the result of this task and its parents.N)r8r.�forgetr5r4r>rrrrO�s
zAsyncResult.forgetcCs |jjj|j|||||d�dS)a�Send revoke signal to all workers.

        Any worker receiving the task, or having reserved the
        task, *must* ignore it.

        Arguments:
            terminate (bool): Also terminate the process currently working
                on the task (if any).
            signal (str): Name of signal to send to process if terminate.
                Default is TERM.
            wait (bool): Wait for replies from workers.
                The ``timeout`` argument specifies the seconds to wait.
                Disabled by default.
            timeout (float): Time in seconds to wait for replies when
                ``wait`` is enabled.
        ��
connection�	terminate�signal�reply�timeoutN)r3�control�revoker4�r:rQrRrS�waitrUrrrrW�s
�zAsyncResult.revokecCs|jjj||||||d�dS)a7Send revoke signal to all workers only for tasks with matching headers values.

        Any worker receiving the task, or having reserved the
        task, *must* ignore it.
        All header fields *must* match.

        Arguments:
            headers (dict[str, Union(str, list)]): Headers to match when revoking tasks.
            terminate (bool): Also terminate the process currently working
                on the task (if any).
            signal (str): Name of signal to send to process if terminate.
                Default is TERM.
            wait (bool): Wait for replies from workers.
                The ``timeout`` argument specifies the seconds to wait.
                Disabled by default.
            timeout (float): Time in seconds to wait for replies when
                ``wait`` is enabled.
        rPN)r3rV�revoke_by_stamped_headers)r:�headersrQrRrSrYrUrrrrZ�s
�z%AsyncResult.revoke_by_stamped_headersT��?c

Cs�|jrdS|	r
t�t�}|r|r|jrt|jdd�}|��|r&|�|�|jr4|r1|j|d�|jS|j	�
|�|j	j||||||||d�S)a�Wait until task is ready, and return its result.

        Warning:
           Waiting for tasks within a task may lead to deadlocks.
           Please read :ref:`task-synchronous-subtasks`.

        Warning:
           Backends use resources to store and transmit results. To ensure
           that resources are released, you must eventually call
           :meth:`~@AsyncResult.get` or :meth:`~@AsyncResult.forget` on
           EVERY :class:`~@AsyncResult` instance returned after calling
           a task.

        Arguments:
            timeout (float): How long to wait, in seconds, before the
                operation times out. This is the setting for the publisher
                (celery client) and is different from `timeout` parameter of
                `@app.task`, which is the setting for the worker. The task
                isn't terminated even if timeout occurs.
            propagate (bool): Re-raise exception if the task failed.
            interval (float): Time to wait (in seconds) before retrying to
                retrieve the result.  Note that this does not have any effect
                when using the RPC/redis result store backends, as they don't
                use polling.
            no_ack (bool): Enable amqp no ack (automatically acknowledge
                message).  If this is :const:`False` then the message will
                **not be acked**.
            follow_parents (bool): Re-raise any exception raised by
                parent tasks.
            disable_sync_subtasks (bool): Disable tasks to wait for sub tasks
                this is the default configuration. CAUTION do not enable this
                unless you must.

        Raises:
            celery.exceptions.TimeoutError: if `timeout` isn't
                :const:`None` and the result does not arrive within
                `timeout` seconds.
            Exception: If the remote call raised an exception then that
                exception will be re-raised in the caller process.
        NTr/)rD)rU�interval�on_interval�no_ack�	propagaterD�
on_message)r?r r	r.�_maybe_reraise_parent_errorrBr8�maybe_throwrIr5rA�wait_for_pending)
r:rUr`r]r_�follow_parentsrDrar^�disable_sync_subtasks�EXCEPTION_STATES�PROPAGATE_STATES�_on_intervalrrr�get�s0-
�zAsyncResult.getcCs"tt|����D]}|��qdSr)�reversed�list�_parentsrc�r:�noderrrrbs
�z'AsyncResult._maybe_reraise_parent_errorccs$�|j}|r|V|j}|sdSdSr�r.rnrrrrm
s��zAsyncResult._parentscks2�|j|d�D]\}}||jdi|��fVqdS)a�Collect results as they return.

        Iterator, like :meth:`get` will wait for the task to complete,
        but will also follow :class:`AsyncResult` and :class:`ResultSet`
        returned by the task, yielding ``(result, value)`` tuples for each
        result in the tree.

        An example would be having the following tasks:

        .. code-block:: python

            from celery import group
            from proj.celery import app

            @app.task(trail=True)
            def A(how_many):
                return group(B.s(i) for i in range(how_many))()

            @app.task(trail=True)
            def B(i):
                return pow2.delay(i)

            @app.task(trail=True)
            def pow2(i):
                return i ** 2

        .. code-block:: pycon

            >>> from celery.result import ResultBase
            >>> from proj.tasks import A

            >>> result = A.delay(10)
            >>> [v for v in result.collect()
            ...  if not isinstance(v, (ResultBase, tuple))]
            [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

        Note:
            The ``Task.trail`` option must be enabled
            so that the list of children is stored in ``result.children``.
            This is the default but enabled explicitly for illustration.

        Yields:
            Tuple[AsyncResult, Any]: tuples containing the result instance
            of the child task, and the return value of that task.
        ��intermediateNr��iterdepsrj)r:rr�kwargs�_�Rrrr�collects�.�zAsyncResult.collectcCs"d}|��D]\}}|��}q|Srrs)r:r@rvrwrrr�get_leafAs
zAsyncResult.get_leafc#sn�td|fg�}|}|r5|��\}�|�fV���r,|��fdd��jp'gD��n|r1t��|s
dSdS)Nc3s�|]}�|fVqdSrr��.0�child�rorr�	<genexpr>P��z'AsyncResult.iterdeps.<locals>.<genexpr>)r�popleft�readyrL�childrenr)r:rr�stack�is_incomplete_streamr.rr}rrtGs�
 �zAsyncResult.iterdepscCs|j|jjvS)z�Return :const:`True` if the task has executed.

        If the task is still running, pending, or is waiting
        for retry then :const:`False` is returned.
        )�stater5�READY_STATESr>rrrr�UszAsyncResult.readycC�|jtjkS)z7Return :const:`True` if the task executed successfully.)r�r�SUCCESSr>rrr�
successful]�zAsyncResult.successfulcCr�)z(Return :const:`True` if the task failed.)r�r�FAILUREr>rrr�failedar�zAsyncResult.failedcOs|jj|i|��dSr)r7�throw�r:�argsrurrrr�eszAsyncResult.throwcCsn|jdur	|��n|j}|d|d|�d�}}}|tjvr+|r+|�||�|��|dur5||j|�|S)N�statusrI�	traceback)r8�_get_task_metarjrrhr��_to_remote_tracebackr4)r:r`rD�cacher�r@�tbrrrrchs
�zAsyncResult.maybe_throwcCs2|rtdur|jjjrtj�|���SdSdSdSr)�tblibr3�conf�task_remote_tracebacks�	Traceback�from_string�as_traceback)r:r�rrrr�ss�z AsyncResult._to_remote_tracebackcCsLt|p	t|jdd�d�}|j|d�D]\}}|�|�|r#|�||�q|S)N�oval)�root�shape)�	formatterrq)rrr4rt�add_arc�add_edge)r:rrr��graphr.rorrr�build_graphws�
�zAsyncResult.build_graphcC�
t|j�S�z`str(self) -> self.id`.��strr4r>rrr�__str__��
zAsyncResult.__str__cCr��z`hash(self) -> hash(self.id)`.��hashr4r>rrr�__hash__�r�zAsyncResult.__hash__cCsdt|�j�d|j�d�S)N�<�: �>)r2r*r4r>rrr�__repr__�szAsyncResult.__repr__cCs.t|t�r|j|jkSt|t�r||jkStSr)�
isinstancerr4r��NotImplemented�r:�otherrrr�__eq__�s



zAsyncResult.__eq__cCs|�|j|jd|j|j�Sr)�	__class__r4r5r3r.r>rrr�__copy__�s�zAsyncResult.__copy__cC�|j|��fSr�r��__reduce_args__r>rrr�
__reduce__��zAsyncResult.__reduce__cCs|j|jdd|jfSr)r4r5r.r>rrrr���zAsyncResult.__reduce_args__cCs|jdur
|j�|�dSdS)z9Cancel pending operations when the instance is destroyed.NrFr>rrr�__del__�s
�zAsyncResult.__del__cCs|��Sr)r�r>rrrr���zAsyncResult.graphcCs|jjSr)r5�supports_native_joinr>rrrr��r�z AsyncResult.supports_native_joincC�|���d�S)Nr��r�rjr>rrrr���zAsyncResult.childrencCs:|r|d}|tjvr|�|j�|��}|�|�|S|S)Nr�)rr��
_set_cacher5�meta_from_decodedr7)r:�metar��drrr�_maybe_set_cache�s

zAsyncResult._maybe_set_cachecCs$|jdur|�|j�|j��S|jSr)r8r�r5�
get_task_metar4r>rrrr��s
zAsyncResult._get_task_metacKst|��g�Sr)�iterr��r:rurrr�
_iter_meta�r�zAsyncResult._iter_metacs.|�d�}|r�fdd�|D�|d<|�_|S)Nr�csg|]}t|�j��qSr)rr3rzr>rr�
<listcomp>���z*AsyncResult._set_cache.<locals>.<listcomp>)rjr8)r:r�r�rr>rr��s


�zAsyncResult._set_cachecC�|��dS)z�Task return value.

        Note:
            When the task has been executed, this contains the return value.
            If the task raised an exception, this will be the exception
            instance.
        rI�r�r>rrrrI�s	zAsyncResult.resultcCr�)z#Get the traceback of a failed task.r�r�r>rrrr��szAsyncResult.tracebackcCr�)a�The tasks current state.

        Possible values includes:

            *PENDING*

                The task is waiting for execution.

            *STARTED*

                The task has been started.

            *RETRY*

                The task is to be retried, possibly because of failure.

            *FAILURE*

                The task raised an exception, or has exceeded the retry limit.
                The :attr:`result` attribute then contains the
                exception raised by the task.

            *SUCCESS*

                The task executed successfully.  The :attr:`result` attribute
                then contains the tasks return value.
        r�r�r>rrrr��szAsyncResult.statecC�|jS)zCompat. alias to :attr:`id`.�r4r>rrr�task_id��zAsyncResult.task_idcC�
||_dSrr�)r:r4rrrr��r�cCr�)N�namer�r>rrrr�r�zAsyncResult.namecCr�)Nr�r�r>rrrr�r�zAsyncResult.argscCr�)Nrur�r>rrrrur�zAsyncResult.kwargscCr�)N�workerr�r>rrrr�r�zAsyncResult.workercCs*|���d�}|rt|tj�st|�S|S)zUTC date and time.�	date_done)r�rjr��datetimer)r:r�rrrr�szAsyncResult.date_donecCr�)N�retriesr�r>rrrr�r�zAsyncResult.retriescCr�)N�queuer�r>rrrr�r�zAsyncResult.queue)NNNNr"�NFNFN)F)TN)FN)Br*r+r,r-r3rr4r5r<�propertyr?�setterrBr6rJrMrOrWrZrrgrhrjrYrbrmrxryrtr�r�r�r�rc�
maybe_reraiser�r�r�r�r�r�r�r�r�r�rr�r�r�r�r�r�r�rI�infor�r�r�r�r�r�rur�r�r�r�rrrrrDs�
�


	
�
�
�H
1

	




		
	









rc@sReZdZdZdZdZdCdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�ZdDdd�ZeZdd�Zdd�Zdd�Zdd�Z		dEd!d"�Zd#d$�Zd%d&�Z	'		dFd(d)�Z	'		dFd*d+�ZdGd,d-�Z		dHd.d/�Z				dId0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Z d:d;�Z!e"d<d=��Z#e"d>d?��Z$e$j%d@d?��Z$e"dAdB��Z&dS)JrzpA collection of results.

    Arguments:
        results (Sequence[AsyncResult]): List of result instances.
    NcKsP||_||_tt|�fd�|_|pt|�|_|jr&|j�t|jdd��dSdS)N)r�Tr/)	�_apprNr	rr7r�_on_fullrB�	_on_ready)r:rNr3�
ready_barrierrurrrr<1s�zResultSet.__init__cCs4||jvr|j�|�|jr|j�|�dSdSdS)zvAdd :class:`AsyncResult` as a new member of the set.

        Does nothing if the result is already a member.
        N)rNrKr��addrHrrrr�9s
�z
ResultSet.addcCs|jjr
|��dSdSr)r5�is_asyncr7r>rrrr�Cs�zResultSet._on_readycCs@t|t�r|j�|�}z	|j�|�WdStyt|��w)z~Remove result from the set; it must be a member.

        Raises:
            KeyError: if the result isn't a member.
        N)r�r�r3rrN�remover1�KeyErrorrHrrrr�Gs
�zResultSet.removecCs&z|�|�WdStyYdSw)zbRemove result from the set if it is a member.

        Does nothing if it's not a member.
        N)r�r�rHrrr�discardTs
�zResultSet.discardcs�j��fdd�|D��dS)z Extend from iterable of results.c3s�|]
}|�jvr|VqdSr�rN�r{�rr>rrr~`s�z#ResultSet.update.<locals>.<genexpr>N)rNrL)r:rNrr>r�update^szResultSet.updatecCsg|jdd�<dS)z!Remove all results from this set.Nr�r>rrr�clearbszResultSet.clearcC�tdd�|jD��S)z�Return true if all tasks successful.

        Returns:
            bool: true if all of the tasks finished
                successfully (i.e. didn't raise an exception).
        cs��|]}|��VqdSr)r��r{rIrrrr~mrz'ResultSet.successful.<locals>.<genexpr>��allrNr>rrrr�f�zResultSet.successfulcCr�)z�Return true if any of the tasks failed.

        Returns:
            bool: true if one of the tasks failed.
                (i.e., raised an exception)
        csr�r)r�r�rrrr~vrz#ResultSet.failed.<locals>.<genexpr>��anyrNr>rrrr�or�zResultSet.failedTcCs|jD]	}|j||d�qdS)N)rDr`)rNrc)r:rDr`rIrrrrcxs
�zResultSet.maybe_throwcCr�)z�Return true if any of the tasks are incomplete.

        Returns:
            bool: true if one of the tasks are still
                waiting for execution.
        css�|]}|��VqdSr�r�r�rrrr~�s�z$ResultSet.waiting.<locals>.<genexpr>r�r>rrr�waiting}r�zResultSet.waitingcCr�)z�Did all of the tasks complete? (either by success of failure).

        Returns:
            bool: true if all of the tasks have been executed.
        csr�rr�r�rrrr~�rz"ResultSet.ready.<locals>.<genexpr>r�r>rrrr��szResultSet.readycCr�)aTask completion count.

        Note that `complete` means `successful` in this context. In other words, the
        return value of this method is the number of ``successful`` tasks.

        Returns:
            int: the number of complete (i.e. successful) tasks.
        css�|]	}t|���VqdSr)�intr�r�rrrr~�s�z,ResultSet.completed_count.<locals>.<genexpr>)�sumrNr>rrr�completed_count�s	zResultSet.completed_countcCs|jD]}|��qdS)z?Forget about (and possible remove the result of) all the tasks.N)rNrOrHrrrrO�s

�zResultSet.forgetFcCs*|jjjdd�|jD�|||||d�dS)a[Send revoke signal to all workers for all tasks in the set.

        Arguments:
            terminate (bool): Also terminate the process currently working
                on the task (if any).
            signal (str): Name of signal to send to process if terminate.
                Default is TERM.
            wait (bool): Wait for replies from worker.
                The ``timeout`` argument specifies the number of seconds
                to wait.  Disabled by default.
            timeout (float): Time in seconds to wait for replies when
                the ``wait`` argument is enabled.
        cSsg|]}|j�qSrr�r�rrrr���z$ResultSet.revoke.<locals>.<listcomp>)rQrUrRrSrTN)r3rVrWrNrXrrrrW�s
�zResultSet.revokecCr�r)r�rNr>rrr�__iter__��
zResultSet.__iter__cCs
|j|S)z`res[i] -> res.results[i]`.r�)r:�indexrrr�__getitem__�r�zResultSet.__getitem__r\c		
Cs&|jr|jn|j||||||||d�S)z�See :meth:`join`.

        This is here for API compatibility with :class:`AsyncResult`,
        in addition it uses :meth:`join_native` if available for the
        current result backend.
        )rUr`r]rDr_rarfr^)r��join_native�join)	r:rUr`r]rDr_rarfr^rrrrj�s	�z
ResultSet.getc		Cs�|rt�t��}	d}
|durtd��g}|jD]/}d}
|r.|t��|	}
|
dkr.td��|j|
|||||d�}
|rB||j|
�q|�|
�q|S)a�Gather the results of all tasks as a list in order.

        Note:
            This can be an expensive operation for result store
            backends that must resort to polling (e.g., database).

            You should consider using :meth:`join_native` if your backend
            supports it.

        Warning:
            Waiting for tasks within a task may lead to deadlocks.
            Please see :ref:`task-synchronous-subtasks`.

        Arguments:
            timeout (float): The number of seconds to wait for results
                before the operation times out.
            propagate (bool): If any of the tasks raises an exception,
                the exception will be re-raised when this flag is set.
            interval (float): Time to wait (in seconds) before retrying to
                retrieve a result from the set.  Note that this does not have
                any effect when using the amqp result store backend,
                as it does not use polling.
            callback (Callable): Optional callback to be called for every
                result received.  Must have signature ``(task_id, value)``
                No results will be returned by this function if a callback
                is specified.  The order of results is also arbitrary when a
                callback is used.  To get access to the result object for
                a particular id you'll have to generate an index first:
                ``index = {r.id: r for r in gres.results.values()}``
                Or you can create new result objects on the fly:
                ``result = app.AsyncResult(task_id)`` (both will
                take advantage of the backend cache anyway).
            no_ack (bool): Automatic message acknowledgment (Note that if this
                is set to :const:`False` then the messages
                *will not be acknowledged*).
            disable_sync_subtasks (bool): Disable tasks to wait for sub tasks
                this is the default configuration. CAUTION do not enable this
                unless you must.

        Raises:
            celery.exceptions.TimeoutError: if ``timeout`` isn't
                :const:`None` and the operation takes longer than ``timeout``
                seconds.
        Nz,Backend does not support on_message callbackgzjoin operation timed out)rUr`r]r_r^rf)	r �time�	monotonicrrNrrjr4rK)r:rUr`r]rDr_rarfr^�
time_start�	remainingrNrIr@rrrr�s0/�
�zResultSet.joincC�|j�||�Sr�r7rBrCrrrrBr�zResultSet.thencCs|jj||||||d�S)a0Backend optimized version of :meth:`iterate`.

        .. versionadded:: 2.2

        Note that this does not support collecting the results
        for different task types using different backends.

        This is currently only supported by the amqp, Redis and cache
        result backends.
        )rUr]r_rar^)r5�iter_native)r:rUr]r_rar^rrrr
s
�zResultSet.iter_nativec	Cs�|rt�|r	dn	dd�t|j�D�}	|rdn
dd�tt|��D�}
|�|||||�D]5\}}t|t�rCg}
|D]	}|
�|�	��q8n|d}
|rR|dt
jvrR|
�|rZ|||
�q+|
|
|	|<q+|
S)a-Backend optimized version of :meth:`join`.

        .. versionadded:: 2.2

        Note that this does not support collecting the results
        for different task types using different backends.

        This is currently only supported by the amqp, Redis and cache
        result backends.
        NcSsi|]\}}|j|�qSrr�)r{�irIrrr�
<dictcomp>7r�z)ResultSet.join_native.<locals>.<dictcomp>cSsg|]}d�qSrr)r{rvrrrr�:sz)ResultSet.join_native.<locals>.<listcomp>rIr�)r �	enumeraterN�range�lenr
r�rlrKrjrrh)r:rUr`r]rDr_rar^rf�order_index�accr�r�r@�children_resultrrrr's*�
�
�zResultSet.join_nativecKs.dd�|jjdd�|jD�fddi|��D�S)Ncss�|]\}}|VqdSrr)r{rvr�rrrr~Lrz'ResultSet._iter_meta.<locals>.<genexpr>cSsh|]}|j�qSrr�r�rrr�	<setcomp>Mr�z'ResultSet._iter_meta.<locals>.<setcomp>�max_iterationsr
)r5�get_manyrNr�rrrr�Ks��
�zResultSet._iter_metacCsdd�|jD�S)Ncss.�|]}|j�|j�r|jtjvr|VqdSr)r5�	is_cachedr4r�rrh)r{�resrrrr~Qs����z0ResultSet._failed_join_report.<locals>.<genexpr>r�r>rrr�_failed_join_reportP�zResultSet._failed_join_reportcCr�r)rrNr>rrr�__len__Ur�zResultSet.__len__cCst|t�r|j|jkStSr)r�rrNr�r�rrrr�Xs
zResultSet.__eq__cCs*dt|�j�dd�dd�|jD���d�S)Nr�z: [�, cs��|]}|jVqdSrr�r�rrrr~^��z%ResultSet.__repr__.<locals>.<genexpr>�]>)r2r*rrNr>rrrr�]s*zResultSet.__repr__cCs$z|jdjWStyYdSw�Nr)rNr��
IndexErrorr>rrrr�`s
�zResultSet.supports_native_joincCs,|jdur|jr|jdjnt��|_|jSr)r�rNr3r�_get_current_objectr>rrrr3gs

�z
ResultSet.appcCr�r)r�)r:r3rrrr3nr�cCs|jr|jjS|jdjSr)r3r5rNr>rrrr5rszResultSet.backend�NNr(r�)NTr\NTNTNr")Nr\TNN)NTr\NTNNT)'r*r+r,r-r�rNr<r�r�r�r�r�r�r�r�rcr�r�r�r�rOrWr�rrjrrBr
rr�rrr�r�r�r�r3r�r5rrrrr$sl



	
		
�
�
�
J
�
�$


rcs�eZdZdZdZdZd�fdd�	Z�fdd�Zd dd�Zd d	d
�Z	dd�Z
d
d�Zdd�ZeZ
dd�Zdd�Zdd�Zdd�Zdd�Zedd��Zed!dd��Z�ZS)"razLike :class:`ResultSet`, but with an associated id.

    This type is returned by :class:`~celery.group`.

    It enables inspection of the tasks state and return values as
    a single entity.

    Arguments:
        id (str): The id of the group.
        results (Sequence[AsyncResult]): List of result instances.
        parent (ResultBase): Parent result of this group.
    Ncs$||_||_t�j|fi|��dSr)r4r.�superr<)r:r4rNr.ru�r�rrr<�szGroupResult.__init__cs|j�|�t���dSr)r5rGr#r�r>r$rrr��szGroupResult._on_readycCs|p|jj�|j|�S)z�Save group-result for later retrieval using :meth:`restore`.

        Example:
            >>> def save_and_restore(result):
            ...     result.save()
            ...     result = GroupResult.restore(result.id)
        )r3r5�
save_groupr4�r:r5rrr�save�szGroupResult.savecCs|p|jj�|j�dS)z.Remove this result if it was previously saved.N)r3r5�delete_groupr4r&rrr�delete�szGroupResult.deletecCr�rr�r>rrrr��r�zGroupResult.__reduce__cCs|j|jfSr)r4rNr>rrrr���zGroupResult.__reduce_args__cCst|jp|j�Sr)�boolr4rNr>rrr�__bool__�rzGroupResult.__bool__cCsFt|t�r|j|jko|j|jko|j|jkSt|t�r!||jkStSr)r�rr4rNr.r�r�r�rrrr��s

�
�

zGroupResult.__eq__c	Cs2dt|�j�d|j�dd�dd�|jD���d�S)Nr�r�z [rcsrrr�r�rrrr~�rz'GroupResult.__repr__.<locals>.<genexpr>r)r2r*r4rrNr>rrrr��s2zGroupResult.__repr__cCr�r�r�r>rrrr��r�zGroupResult.__str__cCr�r�r�r>rrrr��r�zGroupResult.__hash__cCs&|j|jo	|j��fdd�|jD�fS)NcSsg|]}|���qSr)rJr�rrrr��sz(GroupResult.as_tuple.<locals>.<listcomp>)r4r.rJrNr>rrrrJ�s�zGroupResult.as_tuplecCr�rr�r>rrrr��szGroupResult.childrencCs.|pt|jt�s|jnt}|p|j}|�|�S)z&Restore previously saved group result.)r�r3r�rr5�
restore_group)�clsr4r5r3rrr�restore�s
�

zGroupResult.restore)NNNrr")r*r+r,r-r4rNr<r�r'r)r�r�r,�__nonzero__r�r�r�r�rJr�r��classmethodr/�
__classcell__rrr$rrws*



rc@s�eZdZdZd%dd�Zd&dd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
		d'dd�ZeZdd�Z
dd�Zdd�Zedd��Zedd��Zedd ��ZeZed!d"��Zed#d$��ZdS)(rz.Result that we know has already been executed.NcCs4||_||_||_||_||_t�|_|�|�dSr)r4�_result�_state�
_traceback�_namer	r7)r:r4�	ret_valuer�r�r�rrrr<�szEagerResult.__init__FcCrrr	rCrrrrB�r�zEagerResult.thencCr�r)r8r>rrrr��szEagerResult._get_task_metacCr�rr�r>rrrr��r�zEagerResult.__reduce__cCs|j|j|j|jfSr)r4r3r4r5r>rrrr��r�zEagerResult.__reduce_args__cCs|��\}}||�Sr)r�)r:r.r�rrrr��szEagerResult.__copy__cC�dSr(rr>rrrr���zEagerResult.readyTcKsN|rt�|��r|jS|jtjvr%|r"t|jt�r|j�t|j��|jSdSr)r r�rIr�rrhr��	Exception)r:rUr`rfrurrrrj�s
���zEagerResult.getcCsdSrrr>rrrrOr9zEagerResult.forgetcOstj|_dSr)r�REVOKEDr4r�rrrrW
r*zEagerResult.revokecCsd|j�d�S)Nz<EagerResult: r�r�r>rrrr�
r�zEagerResult.__repr__cCs|j|j|j|j|jd�S)N)r�rIr�r�r�)r4r3r4r5r6r>rrrr8s�zEagerResult._cachecCr�)zThe tasks return value.)r3r>rrrrIr�zEagerResult.resultcCr�)zThe tasks state.)r4r>rrrr�r�zEagerResult.statecCr�)z!The traceback if the task failed.)r5r>rrrr�%r�zEagerResult.tracebackcCr8r"rr>rrrr�*sz EagerResult.supports_native_joinr"r")NTT)r*r+r,r-r<rBr�r�r�r�r�rjrYrOrWr�r�r8rIr�r�r�r�rrrrr�s6


�
	


rcs�t����j}t|t�s?|\}}t|ttf�r|n|df\}}|r&t|��}|dur9�j|�fdd�|D�|d�S|||d�S|S)zDeserialize result from tuple.Ncsg|]}t|���qSr)rrz�r3rrr�=sz%result_from_tuple.<locals>.<listcomp>rp)rrr�rrl�tuplerr)r�r3�Resultr�nodesr4r.rr<rr/s

�rr).r-r�r�collectionsr�
contextlibr�weakrefr�dateutil.parserr�kombu.utils.objectsr�vinerrr	�rrr4r
rr3r�
exceptionsrrr�utils.graphrrr��ImportError�__all__rr r&r)r�registerrrrrrrrrr�<module>sR�
	
	bT_W