HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //usr/local/lib/python3.9/site-packages/celery/__pycache__/result.cpython-39.pyc
a

X>h��@stdZddlZddlZddlmZddlmZddlmZddl	m
Z
ddlmZddl
mZmZmZd	d
lmZmZd	dlmZmZd	dlmZd	d
lmZmZmZd	dlmZmZzddl Z Wne!y�dZ Yn0dZ"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�7/usr/local/lib/python3.9/site-packages/celery/result.py�assert_will_not_block$sr ccs0t�}td�zdVWt|�n
t|�0dS�NF�rr
�Zreset_valuerrr�allow_join_result)s
r$ccs0t�}td�zdVWt|�n
t|�0dS�NTr"r#rrr�denied_join_result3s
r&c@seZdZdZdZdS)rzBase class for results.N)�__name__�
__module__�__qualname__�__doc__�parentrrrrr=src@s4eZdZdZdZeZdZdZdhdd�Ze	dd��Z
e
jdd��Z
did	d
�Zdd�Z
d
d�Zdd�Zdd�Zdjdd�Zdkdd�Zdddddddddejejfdd�ZeZdd�Zdd�Zdldd �Zd!d"�Zdmd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Z dnd-d.�Z!e!Z"d/d0�Z#dod1d2�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)przxQuery task state.

    Arguments:
        id (str): See :attr:`id`.
        backend (Backend): See :attr:`backend`.
    NcCsd|durtdt|�����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)�selfr1r2Z	task_namer0r+rrr�__init__Xs�zAsyncResult.__init__cCst|d�r|jSdS)z+If True, task result retrieval is disabled.r6F)�hasattrr6�r7rrr�ignoredfs
zAsyncResult.ignoredcCs
||_dS)z%Enable/disable task result retrieval.N)r6)r7�valuerrrr;msFcCs|jj||d�|j�||�S)Nr,)r2�add_pending_resultr4�then�r7�callbackZon_errorr-rrrr>rszAsyncResult.thencCs|j�|�|Sr�r2�remove_pending_result�r7�resultrrrr3vszAsyncResult._on_fulfilledcCs|j}|j|o|��fdfSr)r+r1�as_tuple)r7r+rrrrEzszAsyncResult.as_tuplecCs0g}|j}|�|j�|dur,|�|���|S)zReturn as a list of task IDs.N)r+�appendr1�extend�as_list)r7�resultsr+rrrrH~szAsyncResult.as_listcCs(d|_|jr|j��|j�|j�dS)z/Forget the result of this task and its parents.N)r5r+�forgetr2r1r:rrrrJ�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)r0�control�revoker1�r7rLrMrN�waitrPrrrrR�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.
        rKN)r0rQ�revoke_by_stamped_headers)r7�headersrLrMrNrTrPrrrrU�s�z%AsyncResult.revoke_by_stamped_headersT��?c

Cs�|jr
dS|	rt�t�}|r>|r>|jr>t|jdd�}|��|rL|�|�|jrh|rb|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:`[email protected]` or :meth:`[email protected]` 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,)r@)rP�interval�on_interval�no_ack�	propagater@�
on_message)r;r r	r+�_maybe_reraise_parent_errorr>r5�maybe_throwrDr2r=Zwait_for_pending)
r7rPr[rXrZZfollow_parentsr@r\rY�disable_sync_subtasks�EXCEPTION_STATES�PROPAGATE_STATESZ_on_intervalrrr�get�s0-
�zAsyncResult.getcCs"tt|����D]}|��qdSr)�reversed�list�_parentsr^�r7�noderrrr]sz'AsyncResult._maybe_reraise_parent_errorccs|j}|r|V|j}qdSr�r+rfrrrre
szAsyncResult._parentscks0|j|d�D]\}}||jfi|��fVqdS)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.
        ��intermediateN��iterdepsrb)r7rj�kwargs�_�Rrrr�collects.zAsyncResult.collectcCs"d}|��D]\}}|��}q|Srrk)r7r<rnrorrr�get_leafAs
zAsyncResult.get_leafc#sftd|fg�}|}|rb|��\}�|�fV���rV|��fdd��jpLgD��q|rt��qdS)Nc3s|]}�|fVqdSrr��.0�child�rgrr�	<genexpr>P�z'AsyncResult.iterdeps.<locals>.<genexpr>)r�popleft�readyrG�childrenr)r7rj�stackZis_incomplete_streamr+rrurrlGs
 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.
        )�stater2�READY_STATESr:rrrryUszAsyncResult.readycCs|jtjkS)z7Return :const:`True` if the task executed successfully.)r|r�SUCCESSr:rrr�
successful]szAsyncResult.successfulcCs|jtjkS)z(Return :const:`True` if the task failed.)r|r�FAILUREr:rrr�failedaszAsyncResult.failedcOs|jj|i|��dSr)r4�throw�r7�argsrmrrrr�eszAsyncResult.throwcCsn|jdur|��n|j}|d|d|�d�}}}|tjvrV|rV|�||�|��|durj||j|�|S)N�statusrD�	traceback)r5�_get_task_metarbrrar��_to_remote_tracebackr1)r7r[r@�cacher|r<�tbrrrr^hs�
zAsyncResult.maybe_throwcCs*|r&tdur&|jjjr&tj�|���SdSr)�tblibr0�confZtask_remote_tracebacks�	TracebackZfrom_stringZas_traceback)r7r�rrrr�ssz AsyncResult._to_remote_tracebackcCsLt|pt|jdd�d�}|j|d�D]"\}}|�|�|r$|�||�q$|S)NZoval)�root�shape)�	formatterri)rrr1rlZadd_arcZadd_edge)r7rjr��graphr+rgrrr�build_graphws�
zAsyncResult.build_graphcCs
t|j�S�z`str(self) -> self.id`.��strr1r:rrr�__str__�szAsyncResult.__str__cCs
t|j�S�z`hash(self) -> hash(self.id)`.��hashr1r:rrr�__hash__�szAsyncResult.__hash__cCsdt|�j�d|j�d�S)N�<�: �>)r/r'r1r:rrr�__repr__�szAsyncResult.__repr__cCs.t|t�r|j|jkSt|t�r*||jkStSr)�
isinstancerr1r��NotImplemented�r7�otherrrr�__eq__�s



zAsyncResult.__eq__cCs|�|j|jd|j|j�Sr)�	__class__r1r2r0r+r:rrr�__copy__�s�zAsyncResult.__copy__cCs|j|��fSr�r��__reduce_args__r:rrr�
__reduce__�szAsyncResult.__reduce__cCs|j|jdd|jfSr)r1r2r+r:rrrr��szAsyncResult.__reduce_args__cCs|jdur|j�|�dS)z9Cancel pending operations when the instance is destroyed.NrAr:rrr�__del__�s
zAsyncResult.__del__cCs|��Sr)r�r:rrrr��szAsyncResult.graphcCs|jjSr)r2�supports_native_joinr:rrrr��sz AsyncResult.supports_native_joincCs|���d�S)Nrz�r�rbr:rrrrz�szAsyncResult.childrencCs:|r6|d}|tjvr6|�|j�|��}|�|�|S|S)Nr�)rr}�
_set_cacher2Zmeta_from_decodedr4)r7�metar|�drrr�_maybe_set_cache�s

zAsyncResult._maybe_set_cachecCs$|jdur|�|j�|j��S|jSr)r5r�r2Z
get_task_metar1r:rrrr��s
zAsyncResult._get_task_metacKst|��g�Sr)�iterr��r7rmrrr�
_iter_meta�szAsyncResult._iter_metacs.|�d�}|r$�fdd�|D�|d<|�_|S)Nrzcsg|]}t|�j��qSr)rr0rrr:rr�
<listcomp>�sz*AsyncResult._set_cache.<locals>.<listcomp>)rbr5)r7r�rzrr:rr��s

�
zAsyncResult._set_cachecCs|��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.
        rD�r�r:rrrrD�s	zAsyncResult.resultcCs|���d�S)z#Get the traceback of a failed task.r�r�r:rrrr��szAsyncResult.tracebackcCs|��dS)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|�szAsyncResult.statecCs|jS)zCompat. alias to :attr:`id`.�r1r:rrr�task_id�szAsyncResult.task_idcCs
||_dSrr�)r7r1rrrr��scCs|���d�S)N�namer�r:rrrr�szAsyncResult.namecCs|���d�S)Nr�r�r:rrrr�szAsyncResult.argscCs|���d�S)Nrmr�r:rrrrmszAsyncResult.kwargscCs|���d�S)N�workerr�r:rrrr�szAsyncResult.workercCs*|���d�}|r&t|tj�s&t|�S|S)zUTC date and time.�	date_done)r�rbr��datetimer)r7r�rrrr�szAsyncResult.date_donecCs|���d�S)N�retriesr�r:rrrr�szAsyncResult.retriescCs|���d�S)N�queuer�r:rrrr�szAsyncResult.queue)NNNN)NF)NFNFN)NFNFN)F)F)TN)FN)Br'r(r)r*r0rr1r2r8�propertyr;�setterr>r3rErHrJrRrUrr`rarbrTr]rerprqrlryrr�r�r^�
maybe_reraiser�r�r�r�r�r�r�r�r�r�rr�r�rzr�r�r�r�rD�infor�r|r�r�r�r�rmr�r�r�r�rrrrrDs��



	�
�
�
H
1

	




		
	









rc@s6eZdZdZdZdZdCdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�ZdDdd�ZeZdd�Zdd�Zdd�Zdd�ZdEd!d"�Zd#d$�Zd%d&�ZdFd(d)�ZdGd*d+�ZdHd,d-�ZdId.d/�ZdJd0d1�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)KrzpA collection of results.

    Arguments:
        results (Sequence[AsyncResult]): List of result instances.
    NcKsL||_||_tt|�fd�|_|p(t|�|_|jrH|j�t|jdd��dS)N)r�Tr,)	�_apprIr	rr4r�_on_fullr>�	_on_ready)r7rIr0Z
ready_barrierrmrrrr81szResultSet.__init__cCs,||jvr(|j�|�|jr(|j�|�dS)zvAdd :class:`AsyncResult` as a new member of the set.

        Does nothing if the result is already a member.
        N)rIrFr��addrCrrrr�9s
z
ResultSet.addcCs|jjr|��dSr)r2�is_asyncr4r:rrrr�CszResultSet._on_readycCsFt|t�r|j�|�}z|j�|�Wnty@t|��Yn0dS)z~Remove result from the set; it must be a member.

        Raises:
            KeyError: if the result isn't a member.
        N)r�r�r0rrI�remover.�KeyErrorrCrrrr�Gs
zResultSet.removecCs&z|�|�Wnty Yn0dS)zbRemove result from the set if it is a member.

        Does nothing if it's not a member.
        N)r�r�rCrrr�discardTszResultSet.discardcs�j��fdd�|D��dS)z Extend from iterable of results.c3s|]}|�jvr|VqdSr�rI�rs�rr:rrrv`rwz#ResultSet.update.<locals>.<genexpr>N)rIrG)r7rIrr:r�update^szResultSet.updatecCsg|jdd�<dS)z!Remove all results from this set.Nr�r:rrr�clearbszResultSet.clearcCstdd�|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).
        css|]}|��VqdSr)r�rsrDrrrrvmrwz'ResultSet.successful.<locals>.<genexpr>��allrIr:rrrrfszResultSet.successfulcCstdd�|jD��S)z�Return true if any of the tasks failed.

        Returns:
            bool: true if one of the tasks failed.
                (i.e., raised an exception)
        css|]}|��VqdSr)r�r�rrrrvvrwz#ResultSet.failed.<locals>.<genexpr>��anyrIr:rrrr�oszResultSet.failedTcCs|jD]}|j||d�qdS)N)r@r[)rIr^)r7r@r[rDrrrr^xs
zResultSet.maybe_throwcCstdd�|jD��S)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�ryr�rrrrv�rwz$ResultSet.waiting.<locals>.<genexpr>r�r:rrr�waiting}szResultSet.waitingcCstdd�|jD��S)z�Did all of the tasks complete? (either by success of failure).

        Returns:
            bool: true if all of the tasks have been executed.
        css|]}|��VqdSrr�r�rrrrv�rwz"ResultSet.ready.<locals>.<genexpr>r�r:rrrry�szResultSet.readycCstdd�|jD��S)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)�intrr�rrrrv�rwz,ResultSet.completed_count.<locals>.<genexpr>)�sumrIr:rrr�completed_count�s	zResultSet.completed_countcCs|jD]}|��qdS)z?Forget about (and possible remove the result of) all the tasks.N)rIrJrCrrrrJ�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��rwz$ResultSet.revoke.<locals>.<listcomp>)rLrPrMrNrON)r0rQrRrIrSrrrrR�s�zResultSet.revokecCs
t|j�Sr)r�rIr:rrr�__iter__�szResultSet.__iter__cCs
|j|S)z`res[i] -> res.results[i]`.r�)r7�indexrrr�__getitem__�szResultSet.__getitem__rWc		
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.
        )rPr[rXr@rZr\r_rY)r��join_native�join)	r7rPr[rXr@rZr\r_rYrrrrb�s	�z
ResultSet.getc		Cs�|r
t�t��}	d}
|dur&td��g}|jD]^}d}
|r\|t��|	}
|
dkr\td��|j|
|||||d�}
|r�||j|
�q0|�|
�q0|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)rPr[rXrZrYr_)	r �time�	monotonicrrIrrbr1rF)r7rPr[rXr@rZr\r_rYZ
time_start�	remainingrIrDr<rrrr��s0/�
�zResultSet.joincCs|j�||�Sr�r4r>r?rrrr>szResultSet.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.
        )rPrXrZr\rY)r2�iter_native)r7rPrXrZr\rYrrrr�s
�zResultSet.iter_nativec	Cs�|r
t�|rdndd�t|j�D�}	|r.dndd�tt|��D�}
|�|||||�D]j\}}t|t�r�g}
|D]}|
�|�	��qpn|d}
|r�|dt
jvr�|
�|r�|||
�qV|
|
|	|<qV|
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�)rs�irDrrr�
<dictcomp>7sz)ResultSet.join_native.<locals>.<dictcomp>cSsg|]}d�qSrr)rsrnrrrr�:rwz)ResultSet.join_native.<locals>.<listcomp>rDr�)r �	enumeraterI�range�lenr�r�rdrFrbrra)r7rPr[rXr@rZr\rYr_Zorder_index�accr�r�r<Zchildren_resultrrrr�'s(�
�
zResultSet.join_nativecKs.dd�|jjdd�|jD�fddi|��D�S)Ncss|]\}}|VqdSrr)rsrnr�rrrrvLrwz'ResultSet._iter_meta.<locals>.<genexpr>cSsh|]
}|j�qSrr�r�rrr�	<setcomp>Mrwz'ResultSet._iter_meta.<locals>.<setcomp>Zmax_iterationsr
)r2Zget_manyrIr�rrrr�Ks���zResultSet._iter_metacCsdd�|jD�S)Ncss,|]$}|j�|j�r|jtjvr|VqdSr)r2Z	is_cachedr1r|rra)rs�resrrrrvQs�z0ResultSet._failed_join_report.<locals>.<genexpr>r�r:rrr�_failed_join_reportPszResultSet._failed_join_reportcCs
t|j�Sr)r�rIr:rrr�__len__UszResultSet.__len__cCst|t�r|j|jkStSr)r�rrIr�r�rrrr�Xs
zResultSet.__eq__cCs*dt|�j�dd�dd�|jD���d�S)Nr�z: [�, css|]}|jVqdSrr�r�rrrrv^rwz%ResultSet.__repr__.<locals>.<genexpr>�]>)r/r'r�rIr:rrrr�]szResultSet.__repr__cCs&z|jdjWSty Yn0dS�Nr)rIr��
IndexErrorr:rrrr�`szResultSet.supports_native_joincCs,|jdur&|jr|jdjnt��|_|jSr�)r�rIr0rZ_get_current_objectr:rrrr0gs

�z
ResultSet.appcCs
||_dSr)r�)r7r0rrrr0nscCs|jr|jjS|jdjSr�)r0r2rIr:rrrr2rszResultSet.backend)NN)NT)NFNFN)NTrWNTNTN)NTrWNTNTN)NF)NrWTNN)NTrWNTNNT)'r'r(r)r*r�rIr8r�r�r�r�r�r�rr�r^r�r�ryr�rJrRr�r�rbr�r>r�r�r�r�r�r�r�r�r�r0r�r2rrrrr$sj



		
	�
�
�
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)r1r+�superr8)r7r1rIr+rm�r�rrr8�szGroupResult.__init__cs|j�|�t���dSr)r2rBr�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)
        )r0r2Z
save_groupr1�r7r2rrr�save�szGroupResult.savecCs|p
|jj�|j�dS)z.Remove this result if it was previously saved.N)r0r2Zdelete_groupr1r�rrr�delete�szGroupResult.deletecCs|j|��fSrr�r:rrrr��szGroupResult.__reduce__cCs|j|jfSr)r1rIr:rrrr��szGroupResult.__reduce_args__cCst|jp|j�Sr)�boolr1rIr:rrr�__bool__�szGroupResult.__bool__cCsFt|t�r.|j|jko,|j|jko,|j|jkSt|t�rB||jkStSr)r�rr1rIr+r�r�r�rrrr��s

�
�

zGroupResult.__eq__c	Cs2dt|�j�d|j�dd�dd�|jD���d�S)Nr�r�z [r�css|]}|jVqdSrr�r�rrrrv�rwz'GroupResult.__repr__.<locals>.<genexpr>r�)r/r'r1r�rIr:rrrr��szGroupResult.__repr__cCs
t|j�Sr�r�r:rrrr��szGroupResult.__str__cCs
t|j�Sr�r�r:rrrr��szGroupResult.__hash__cCs&|j|jo|j��fdd�|jD�fS)NcSsg|]}|���qSr)rEr�rrrr��rwz(GroupResult.as_tuple.<locals>.<listcomp>)r1r+rErIr:rrrrE�s�zGroupResult.as_tuplecCs|jSrr�r:rrrrz�szGroupResult.childrencCs.|pt|jt�s|jnt}|p"|j}|�|�S)z&Restore previously saved group result.)r�r0r�rr2Z
restore_group)�clsr1r2r0rrr�restore�s
�
zGroupResult.restore)NNN)N)N)NN)r'r(r)r*r1rIr8r�r�r�r�r�r��__nonzero__r�r�r�r�rEr�rz�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)r1�_result�_state�
_traceback�_namer	r4)r7r1Z	ret_valuer|r�r�rrrr8�szEagerResult.__init__FcCs|j�||�Srr�r?rrrr>�szEagerResult.thencCs|jSr)r5r:rrrr��szEagerResult._get_task_metacCs|j|��fSrr�r:rrrr��szEagerResult.__reduce__cCs|j|j|j|jfSr)r1r�r�r�r:rrrr��szEagerResult.__reduce_args__cCs|��\}}||�Sr)r�)r7r�r�rrrr��szEagerResult.__copy__cCsdSr%rr:rrrry�szEagerResult.readyTcKsN|r
t�|��r|jS|jtjvrJ|rDt|jt�r:|jnt|j��|jSdSr)r rrDr|rrar��	Exception)r7rPr[r_rmrrrrb�s�
�zEagerResult.getcCsdSrrr:rrrrJszEagerResult.forgetcOstj|_dSr)rZREVOKEDr�r�rrrrR
szEagerResult.revokecCsd|j�d�S)Nz<EagerResult: r�r�r:rrrr�
szEagerResult.__repr__cCs|j|j|j|j|jd�S)N)r�rDr�r�r�)r1r�r�r�r�r:rrrr5s�zEagerResult._cachecCs|jS)zThe tasks return value.)r�r:rrrrDszEagerResult.resultcCs|jS)zThe tasks state.)r�r:rrrr|szEagerResult.statecCs|jS)z!The traceback if the task failed.)r�r:rrrr�%szEagerResult.tracebackcCsdSr!rr:rrrr�*sz EagerResult.supports_native_join)NN)NF)NTT)r'r(r)r*r8r>r�r�r�r�ryrbrTrJrRr�r�r5rDr|r�r�r�rrrrr�s4

�

	


rcs�t����j}t|t�s~|\}}t|ttf�r2|n|df\}}|rLt|��}|durr�j|�fdd�|D�|d�S|||d�S|S)zDeserialize result from tuple.Ncsg|]}t|���qSr)rrr�r0rrr�=rwz%result_from_tuple.<locals>.<listcomp>rh)rrr�rrd�tuplerr)r�r0�Resultr��nodesr1r+rrrr/s

�r)N).r*r�r��collectionsr�
contextlibr�weakrefrZdateutil.parserrZkombu.utils.objectsrZvinerrr	�rrr�r
rr0r�
exceptionsrrrZutils.graphrrr��ImportError�__all__rr r$r&r�registerrrrrrrrrr�<module>sN

	
	bT_W