ó
P'—^c           @@  sø  d  Z  d d l m Z d d l Z d d l Z d d l m Z d d l m Z d d l	 m	 Z	 d d l
 m Z d d l m Z d	 d
 l m Z d	 d l m Z d	 d l m Z m Z d	 d l m Z d	 d l m Z m Z d	 d l m Z m Z d	 d l m Z m Z m Z m  Z  d	 d l! m" Z" d d d d d d g Z# d Z$ d „  Z% e d „  ƒ Z& d e' f d „  ƒ  YZ( d e( f d „  ƒ  YZ) e) Z* d e( f d „  ƒ  YZ+ d e+ f d „  ƒ  YZ, d e, f d  „  ƒ  YZ- d e) f d! „  ƒ  YZ. e/ d" „ Z0 e0 Z1 d S(#   sU   
    celery.result
    ~~~~~~~~~~~~~

    Task results/state and groups of results.

i    (   t   absolute_importN(   t   deque(   t   contextmanager(   t   copy(   t   cached_property(   t   OrderedDicti   (   t   current_app(   t   states(   t   _set_task_join_will_blockt   task_join_will_block(   t   app_or_default(   t   DependencyGrapht   GraphFormatter(   t   IncompleteStreamt   TimeoutError(   t   itemst   ranget   string_tt	   monotonic(   t
   deprecatedt
   ResultBaset   AsyncResultt	   ResultSett   GroupResultt   EagerResultt   result_from_tuplesÚ   Never call result.get() within a task!
See http://docs.celeryq.org/en/latest/userguide/tasks.html#task-synchronous-subtasks

In Celery 3.2 this will result in an exception being
raised instead of just being a warning.
c           C@  s#   t  ƒ  r t j t t ƒ ƒ n  d  S(   N(   R	   t   warningst   warnt   RuntimeWarningt   E_WOULDBLOCK(    (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   assert_will_not_block+   s    	c          c@  s.   t  ƒ  }  t t ƒ z	 d  VWd  t |  ƒ Xd  S(   N(   R	   R   t   False(   t   reset_value(    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   allow_join_result0   s
    	
	c           B@  s   e  Z d  Z d Z RS(   s   Base class for all resultsN(   t   __name__t
   __module__t   __doc__t   Nonet   parent(    (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR   :   s   c           B@  sî  e  Z d  Z d% Z e Z d% Z d% Z d% d% d% d% d „ Z d „  Z	 e	 Z
 d „  Z d% e d% e d% d „ Z d% e d e e e j e j d „ Z e Z d „  Z d „  Z e d	 „ Z d
 „  Z e d „ Z d „  Z d „  Z d „  Z d „  Z e d% d „ Z d „  Z d „  Z d „  Z  d „  Z! d „  Z" d „  Z# d „  Z$ d „  Z% d „  Z& e' d „  ƒ Z( e) d „  ƒ Z* e) d „  ƒ Z+ d „  Z, d „  Z- d „  Z. e) d  „  ƒ Z/ e/ Z0 e) d! „  ƒ Z1 e) d" „  ƒ Z2 e2 Z3 e) d# „  ƒ Z4 e4 j5 d$ „  ƒ Z4 RS(&   sb   Query task state.

    :param id: see :attr:`id`.
    :keyword backend: see :attr:`backend`.

    c         C@  sU   t  | p |  j ƒ |  _ | |  _ | p0 |  j j |  _ | |  _ | |  _ d  |  _ d  S(   N(   R
   t   appt   idt   backendt	   task_nameR&   R%   t   _cache(   t   selfR(   R)   R*   R'   R&   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   __init__S   s    			c         C@  s(   |  j  } |  j | o | j ƒ  f d  f S(   N(   R&   R(   t   as_tupleR%   (   R,   R&   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR.   \   s    	c         C@  s    d |  _ |  j j |  j ƒ d S(   s;   Forget about (and possibly remove the result of) this task.N(   R%   R+   R)   t   forgetR(   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR/   a   s    	c         C@  s8   |  j  j j |  j d | d | d | d | d | ƒd S(   sW  Send revoke signal to all workers.

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

        :keyword terminate: Also terminate the process currently working
            on the task (if any).
        :keyword signal: Name of signal to send to process if terminate.
            Default is TERM.
        :keyword wait: Wait for replies from workers.  Will wait for 1 second
           by default or you can specify a custom ``timeout``.
        :keyword timeout: Time in seconds to wait for replies if ``wait``
                          enabled.

        t
   connectiont	   terminatet   signalt   replyt   timeoutN(   R'   t   controlt   revokeR(   (   R,   R0   R1   R2   t   waitR4   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR6   f   s    g      à?c      
   C@  sÍ   t  ƒ  d } | r5 | r5 |  j r5 |  j } | ƒ  n  |  j rX | rQ |  j ƒ  n  |  j S|  j j |  j	 d | d | d | d | ƒ}	 |	 rÉ |  j
 |	 ƒ |	 d }
 |
 | k rÁ | rÁ |	 d ‚ n  |	 d Sd S(   sl  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`.

        :keyword timeout: How long to wait, in seconds, before the
                          operation times out.
        :keyword propagate: Re-raise exception if the task failed.
        :keyword interval: Time to wait (in seconds) before retrying to
           retrieve the result.  Note that this does not have any effect
           when using the amqp result store backend, as it does not
           use polling.
        :keyword no_ack: Enable amqp no ack (automatically acknowledge
            message).  If this is :const:`False` then the message will
            **not be acked**.
        :keyword follow_parents: Reraise any exception raised by parent task.

        :raises celery.exceptions.TimeoutError: if `timeout` is not
            :const:`None` and the result does not arrive within `timeout`
            seconds.

        If the remote call raised an exception then that exception will
        be re-raised.

        R4   t   intervalt   on_intervalt   no_ackt   statust   resultN(   R   R%   R&   t   _maybe_reraise_parent_errorR+   t   maybe_reraiseR<   R)   t   wait_forR(   t   _maybe_set_cache(   R,   R4   t	   propagateR8   R:   t   follow_parentst   EXCEPTION_STATESt   PROPAGATE_STATESR9   t   metaR;   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   get{   s(    	
			
c         C@  s1   x* t  t |  j ƒ  ƒ ƒ D] } | j ƒ  q Wd  S(   N(   t   reversedt   listt   _parentsR>   (   R,   t   node(    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR=   ³   s    c         c@  s(   |  j  } x | r# | V| j  } q Wd  S(   N(   R&   (   R,   RJ   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRI   ·   s    		c         k@  s;   x4 |  j  d | ƒ D]  \ } } | | j |   f Vq Wd S(   s	  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

        Note that the ``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.

        Calling :meth:`collect` would return:

        .. code-block:: python

            >>> 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]

        t   intermediateN(   t   iterdepsRF   (   R,   RK   t   kwargst   _t   R(    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   collect½   s    *c         C@  s3   d  } x& |  j ƒ  D] \ } } | j ƒ  } q W| S(   N(   R%   RL   RF   (   R,   t   valueRN   RO   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   get_leafê   s    c         #@  sŠ   t  d  |  f g ƒ } xn | r… | j ƒ  \ } ‰  | ˆ  f Vˆ  j ƒ  rp | j ‡  f d †  ˆ  j pe g  Dƒ ƒ q | s t ƒ  ‚ q q Wd  S(   Nc         3@  s   |  ] } ˆ  | f Vq d  S(   N(    (   t   .0t   child(   RJ   (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pys	   <genexpr>÷   s    (   R   R%   t   popleftt   readyt   extendt   childrenR   (   R,   RK   t   stackR&   (    (   RJ   s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRL   ð   s    	)c         C@  s   |  j  |  j j k S(   s¯   Returns :const:`True` if the task has been executed.

        If the task is still running, pending, or is waiting
        for retry then :const:`False` is returned.

        (   t   stateR)   t   READY_STATES(   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRV   ü   s    c         C@  s   |  j  t j k S(   s8   Returns :const:`True` if the task executed successfully.(   RZ   R   t   SUCCESS(   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt
   successful  s    c         C@  s   |  j  t j k S(   s)   Returns :const:`True` if the task failed.(   RZ   R   t   FAILURE(   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   failed	  s    c         C@  s"   |  j  t j k r |  j ‚ n  d  S(   N(   RZ   R   RD   R<   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR>     s    c         C@  st   t  d | p! t d |  j d d ƒ ƒ } xF |  j d | ƒ D]2 \ } } | j | ƒ | r: | j | | ƒ q: q: W| S(   Nt	   formattert   roott   shapet   ovalRK   (   R   R   R(   RL   t   add_arct   add_edge(   R,   RK   R`   t   graphR&   RJ   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   build_graph  s    !c         C@  s   t  |  j ƒ S(   s   `str(self) -> self.id`(   t   strR(   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   __str__  s    c         C@  s   t  |  j ƒ S(   s   `hash(self) -> hash(self.id)`(   t   hashR(   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   __hash__  s    c         C@  s   d j  t |  ƒ j |  j ƒ S(   Ns
   <{0}: {1}>(   t   formatt   typeR"   R(   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   __repr__#  s    c         C@  s?   t  | t ƒ r | j |  j k St  | t ƒ r; | |  j k St S(   N(   t
   isinstanceR   R(   R   t   NotImplemented(   R,   t   other(    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   __eq__&  s
    c         C@  s   |  j  | ƒ S(   N(   Rr   (   R,   Rq   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   __ne__-  s    c         C@  s(   |  j  |  j |  j |  j |  j |  j ƒ S(   N(   t	   __class__R(   R)   R*   R'   R&   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   __copy__0  s    c         C@  s   |  j  |  j ƒ  f S(   N(   Rt   t   __reduce_args__(   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt
   __reduce__5  s    c         C@  s   |  j  |  j |  j d  |  j f S(   N(   R(   R)   R*   R%   R&   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRv   8  s    c         C@  s   d  |  _ d  S(   N(   R%   R+   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   __del__;  s    c         C@  s
   |  j  ƒ  S(   N(   Rg   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRf   >  s    c         C@  s
   |  j  j S(   N(   R)   t   supports_native_join(   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRy   B  s    c         C@  s   |  j  ƒ  j d ƒ S(   NRX   (   t   _get_task_metaRF   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRX   F  s    c         C@  sB   | r> | d } | t  j k s. | t  j k r> |  j | ƒ Sn  | S(   NR;   (   R   R\   RD   t
   _set_cache(   R,   RE   RZ   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR@   J  s
    
c         C@  s2   |  j  d  k r+ |  j |  j j |  j ƒ ƒ S|  j  S(   N(   R+   R%   R@   R)   t   get_task_metaR(   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRz   Q  s    c         C@  sN   | j  d ƒ } | rA g  | D] } t | |  j ƒ ^ q | d <n  | |  _ | S(   NRX   (   RF   R   R'   R+   (   R,   t   dRX   RT   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR{   V  s
    ,	c         C@  s   |  j  ƒ  d S(   s–   When the task has been executed, this contains the return value.
        If the task raised an exception, this will be the exception
        instance.R<   (   Rz   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR<   _  s    c         C@  s   |  j  ƒ  j d ƒ S(   s#   Get the traceback of a failed task.t	   traceback(   Rz   RF   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR~   g  s    c         C@  s   |  j  ƒ  d S(   s   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;   (   Rz   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRZ   l  s    c         C@  s   |  j  S(   s   compat alias to :attr:`id`(   R(   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   task_id  s    c         C@  s   | |  _  d  S(   N(   R(   (   R,   R(   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR   ’  s    N(6   R"   R#   R$   R%   R'   R   R(   R)   R-   R.   t   serializableR/   R   R6   t   TrueR   RC   RD   RF   R7   R=   RI   RP   RR   RL   RV   R]   R_   R>   Rg   Ri   Rk   Rn   Rr   Rs   Ru   Rw   Rv   Rx   R   Rf   t   propertyRy   RX   R@   Rz   R{   R<   t   infoR~   RZ   R;   R   t   setter(    (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR   A   sb   				3		-						
													c           B@  s‘  e  Z d  Z d! Z d! Z d! d „ Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d! e d! e d! d „ Z d „  Z d „  Z e d d ƒ d! e d d „ ƒ Z d! e d d! e d „ Z d! e d d! e d „ Z d! d e d „ Z d! e d d! e d „ Z d „  Z d „  Z d „  Z  d „  Z! d „  Z" e# d „  ƒ Z$ e# d „  ƒ Z% e# d  „  ƒ Z& RS("   sW   Working with more than one result.

    :param results: List of result instances.

    c         K@  s%   t  | p |  j ƒ |  _ | |  _ d  S(   N(   R
   R'   t   results(   R,   R…   R'   RM   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR-   £  s    c         C@  s&   | |  j  k r" |  j  j | ƒ n  d S(   sw   Add :class:`AsyncResult` as a new member of the set.

        Does nothing if the result is already a member.

        N(   R…   t   append(   R,   R<   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   add§  s    c         C@  s\   t  | t ƒ r$ |  j j | ƒ } n  y |  j j | ƒ Wn t k
 rW t | ƒ ‚ n Xd S(   st   Remove result from the set; it must be a member.

        :raises KeyError: if the result is not a member.

        N(   Ro   R   R'   R   R…   t   removet
   ValueErrort   KeyError(   R,   R<   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRˆ   °  s    c         C@  s)   y |  j  | ƒ Wn t k
 r$ n Xd S(   sc   Remove result from the set if it is a member.

        If it is not a member, do nothing.

        N(   Rˆ   RŠ   (   R,   R<   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   discard½  s    c         @  s$   ˆ  j  j ‡  f d †  | Dƒ ƒ d S(   sI   Update set with the union of itself and an iterable with
        results.c         3@  s$   |  ] } | ˆ  j  k r | Vq d  S(   N(   R…   (   RS   t   r(   R,   (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pys	   <genexpr>Ë  s    N(   R…   RW   (   R,   R…   (    (   R,   s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   updateÈ  s    c         C@  s   g  |  j  (d S(   s!   Remove all results from this set.N(   R…   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   clearÍ  s    c         C@  s   t  d „  |  j Dƒ ƒ S(   s¤   Was all of the tasks successful?

        :returns: :const:`True` if all of the tasks finished
            successfully (i.e. did not raise an exception).

        c         s@  s   |  ] } | j  ƒ  Vq d  S(   N(   R]   (   RS   R<   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pys	   <genexpr>Ø  s    (   t   allR…   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR]   Ñ  s    c         C@  s   t  d „  |  j Dƒ ƒ S(   s‰   Did any of the tasks fail?

        :returns: :const:`True` if one of the tasks failed.
            (i.e., raised an exception)

        c         s@  s   |  ] } | j  ƒ  Vq d  S(   N(   R_   (   RS   R<   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pys	   <genexpr>á  s    (   t   anyR…   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR_   Ú  s    c         C@  s"   x |  j  D] } | j ƒ  q
 Wd  S(   N(   R…   R>   (   R,   R<   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR>   ã  s    c         C@  s   t  d „  |  j Dƒ ƒ S(   sŒ   Are any of the tasks incomplete?

        :returns: :const:`True` if one of the tasks are still
            waiting for execution.

        c         s@  s   |  ] } | j  ƒ  Vq d  S(   N(   RV   (   RS   R<   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pys	   <genexpr>î  s    (   R   R…   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   waitingç  s    c         C@  s   t  d „  |  j Dƒ ƒ S(   sœ   Did all of the tasks complete? (either by success of failure).

        :returns: :const:`True` if all of the tasks has been
            executed.

        c         s@  s   |  ] } | j  ƒ  Vq d  S(   N(   RV   (   RS   R<   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pys	   <genexpr>÷  s    (   R   R…   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRV   ð  s    c         C@  s   t  d „  |  j Dƒ ƒ S(   sR   Task completion count.

        :returns: the number of tasks completed.

        c         s@  s!   |  ] } t  | j ƒ  ƒ Vq d  S(   N(   t   intR]   (   RS   R<   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pys	   <genexpr>ÿ  s    (   t   sumR…   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   completed_countù  s    c         C@  s"   x |  j  D] } | j ƒ  q
 Wd S(   s?   Forget about (and possible remove the result of) all the tasks.N(   R…   R/   (   R,   R<   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR/     s    c         C@  sN   |  j  j j g  |  j D] } | j ^ q d | d | d | d | d | ƒd S(   s  Send revoke signal to all workers for all tasks in the set.

        :keyword terminate: Also terminate the process currently working
            on the task (if any).
        :keyword signal: Name of signal to send to process if terminate.
            Default is TERM.
        :keyword wait: Wait for replies from worker.  Will wait for 1 second
           by default or you can specify a custom ``timeout``.
        :keyword timeout: Time in seconds to wait for replies if ``wait``
                          enabled.

        R0   R4   R1   R2   R3   N(   R'   R5   R6   R…   R(   (   R,   R0   R1   R2   R7   R4   RŒ   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR6     s    +c         C@  s   t  |  j ƒ S(   N(   t   iterR…   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   __iter__  s    c         C@  s   |  j  | S(   s   `res[i] -> res.results[i]`(   R…   (   R,   t   index(    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   __getitem__  s    s   3.2s   3.3g      à?c   	      c@  s  d } t  d „  |  j Dƒ ƒ } xè | r	t ƒ  } xy t | ƒ D]k \ } } | j ƒ  r‡ | j d | ol | | d | ƒ V| j | ƒ q> | j j r> t	 j
 | j j ƒ q> q> Wx | D] } | j | d ƒ q´ Wt	 j
 | ƒ | | 7} | r" | | k r" t d ƒ ‚ q" q" Wd S(   s<   Deprecated method, use :meth:`get` with a callback argument.g        c         s@  s$   |  ] } | j  t | ƒ f Vq d  S(   N(   R(   R   (   RS   R<   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pys	   <genexpr>#  s   R4   RA   s   The operation timed outN(   R   R…   t   setR   RV   RF   R‡   R)   t   subpolling_intervalt   timet   sleept   popR%   R   (	   R,   R4   RA   R8   t   elapsedR…   t   removedR   R<   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   iterate  s$    			
c         C@  s:   |  j  r |  j n |  j d | d | d | d | d | ƒ S(   sÆ   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.

        R4   RA   R8   t   callbackR:   (   Ry   t   join_nativet   join(   R,   R4   RA   R8   R¡   R:   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRF   7  s    	c      
   C@  s¹   t  ƒ  t ƒ  } d } g  } x– |  j D]‹ }	 d } | rg | t ƒ  | } | d k rg t d ƒ ‚ qg n  |	 j d | d | d | d | ƒ }
 | r¤ | |	 j |
 ƒ q& | j |
 ƒ q& W| S(   sˆ  Gathers 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`.

        :keyword timeout: The number of seconds to wait for results before
                          the operation times out.

        :keyword propagate: If any of the tasks raises an exception, the
                            exception will be re-raised.

        :keyword interval: 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.

        :keyword callback: 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 will 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).

        :keyword no_ack: Automatic message acknowledgement (Note that if this
            is set to :const:`False` then the messages *will not be
            acknowledged*).

        :raises celery.exceptions.TimeoutError: if ``timeout`` is not
            :const:`None` and the operation takes longer than ``timeout``
            seconds.

        g        s   join operation timed outR4   RA   R8   R:   N(   R   R   R%   R…   R   RF   R(   R†   (   R,   R4   RA   R8   R¡   R:   t
   time_startt	   remainingR…   R<   RQ   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR£   D  s"    1		c         C@  sK   |  j  } | s t g  ƒ S|  j j t d „  | Dƒ ƒ d | d | d | ƒS(   s1  Backend 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.

        c         s@  s   |  ] } | j  Vq d  S(   N(   R(   (   RS   RŒ   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pys	   <genexpr>š  s    R4   R8   R:   (   R…   R•   R)   t   get_manyR™   (   R,   R4   R8   R:   R…   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   iter_nativeŠ  s    	
	c         C@  sÝ   t  ƒ  | r d n t d „  t |  j ƒ Dƒ ƒ } | r> d n" g  t t |  ƒ ƒ D] } d ^ qQ } xs |  j | | | ƒ D]\ \ }	 }
 |
 d } | r± |
 d t j	 k r± | ‚ n  | rÇ | |	 | ƒ qy | | | |	 <qy W| S(   s.  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.

        c         s@  s$   |  ] \ } } | j  | f Vq d  S(   N(   R(   (   RS   t   iR<   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pys	   <genexpr>­  s    R<   R;   N(
   R   R%   t   dictt	   enumerateR…   R   t   lenR§   R   RD   (   R,   R4   RA   R8   R¡   R:   t   order_indexRN   t   accR   RE   RQ   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR¢   ž  s    1"
	c         C@  s   d „  |  j  Dƒ S(   Nc         s@  s<   |  ]2 } | j  j | j ƒ r | j t j k r | Vq d  S(   N(   R)   t	   is_cachedR(   RZ   R   RD   (   RS   t   res(    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pys	   <genexpr>»  s    (   R…   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   _failed_join_reportº  s    c         C@  s   t  |  j ƒ S(   N(   R«   R…   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   __len__¿  s    c         C@  s#   t  | t ƒ r | j |  j k St S(   N(   Ro   R   R…   Rp   (   R,   Rq   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRr   Â  s    c         C@  s   |  j  | ƒ S(   N(   Rr   (   R,   Rq   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRs   Ç  s    c         C@  s/   d j  t |  ƒ j d j d „  |  j Dƒ ƒ ƒ S(   Ns   <{0}: [{1}]>s   , c         s@  s   |  ] } | j  Vq d  S(   N(   R(   (   RS   RŒ   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pys	   <genexpr>Ì  s    (   Rl   Rm   R"   R£   R…   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRn   Ê  s    c         C@  s   |  j  S(   s$   Deprecated alias to :attr:`results`.(   R…   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   subtasksÎ  s    c         C@  s*   y |  j  d j SWn t k
 r% n Xd  S(   Ni    (   R…   Ry   t
   IndexError(   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRy   Ó  s    c         C@  s!   |  j  r |  j  j S|  j d j S(   Ni    (   R'   R)   R…   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR)   Ú  s    N('   R"   R#   R$   R%   R'   R…   R-   R‡   Rˆ   R‹   R   RŽ   R]   R_   R>   R‘   RV   R”   R/   R   R6   R–   R˜   R   R   R    RF   R£   R§   R¢   R°   R±   Rr   Rs   Rn   R‚   R²   Ry   R)   (    (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR   ˜  sJ   																						E					c           B@  s­   e  Z d  Z d Z d Z d d d „ Z d d „ Z d d „ Z d „  Z	 d „  Z
 d „  Z e Z d „  Z d „  Z d	 „  Z d
 „  Z e Z e d „  ƒ Z e d d „ ƒ Z RS(   sj  Like :class:`ResultSet`, but with an associated id.

    This type is returned by :class:`~celery.group`, and the
    deprecated TaskSet, meth:`~celery.task.TaskSet.apply_async` method.

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

    :param id: The id of the group.
    :param results: List of result instances.

    c         K@  s    | |  _  t j |  | |  d  S(   N(   R(   R   R-   (   R,   R(   R…   RM   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR-   ó  s    	c         C@  s   | p |  j  j j |  j |  ƒ S(   sæ   Save group-result for later retrieval using :meth:`restore`.

        Example::

            >>> def save_and_restore(result):
            ...     result.save()
            ...     result = GroupResult.restore(result.id)

        (   R'   R)   t
   save_groupR(   (   R,   R)   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   save÷  s    
c         C@  s    | p |  j  j j |  j ƒ d S(   s.   Remove this result if it was previously saved.N(   R'   R)   t   delete_groupR(   (   R,   R)   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   delete  s    c         C@  s   |  j  |  j ƒ  f S(   N(   Rt   Rv   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRw     s    c         C@  s   |  j  |  j f S(   N(   R(   R…   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRv   
  s    c         C@  s   t  |  j p |  j ƒ S(   N(   t   boolR(   R…   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   __bool__  s    c         C@  s5   t  | t ƒ r1 | j |  j k o0 | j |  j k St S(   N(   Ro   R   R(   R…   Rp   (   R,   Rq   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRr     s    "c         C@  s   |  j  | ƒ S(   N(   Rr   (   R,   Rq   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRs     s    c         C@  s5   d j  t |  ƒ j |  j d j d „  |  j Dƒ ƒ ƒ S(   Ns   <{0}: {1} [{2}]>s   , c         s@  s   |  ] } | j  Vq d  S(   N(   R(   (   RS   RŒ   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pys	   <genexpr>  s    (   Rl   Rm   R"   R(   R£   R…   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRn     s    c         C@  s)   |  j  g  |  j D] } | j ƒ  ^ q f S(   N(   R(   R…   R.   (   R,   RŒ   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR.     s    c         C@  s   |  j  S(   N(   R…   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRX   !  s    c         C@  s+   | p! |  j  r |  j  j n t j j | ƒ S(   s&   Restore previously saved group result.(   R'   R)   R   t   restore_group(   R,   R(   R)   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   restore%  s    $N(   R"   R#   R$   R%   R(   R…   R-   Rµ   R·   Rw   Rv   R¹   t   __nonzero__Rr   Rs   Rn   R.   R€   R‚   RX   t   classmethodR»   (    (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR   ß  s$   							t   TaskSetResultc           B@  sS   e  Z d  Z d d „ Z d „  Z e d „  ƒ Z e d „  ƒ Z e j	 d „  ƒ Z RS(   s*   Deprecated version of :class:`GroupResult`c         K@  s3   d | k r | d } n  t  j |  | | |  d  S(   NR²   (   R   R-   (   R,   t
   taskset_idR…   RM   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR-   0  s    c         C@  s   t  |  j ƒ S(   s1   Deprecated.   Use ``iter(self.results)`` instead.(   R•   R…   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   itersubtasks7  s    c         C@  s
   t  |  ƒ S(   s   Deprecated: Use ``len(r)``.(   R«   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   total;  s    c         C@  s   |  j  S(   s   compat alias to :attr:`self.id`(   R(   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR¿   @  s    c         C@  s   | |  _  d  S(   N(   R(   (   R,   R(   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR¿   E  s    N(
   R"   R#   R$   R%   R-   RÀ   R‚   RÁ   R¿   R„   (    (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR¾   -  s   	c           B@  s¿   e  Z d  Z d Z d d „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d e d „ Z e Z d „  Z d	 „  Z d
 „  Z e d „  ƒ Z e d „  ƒ Z e Z e d „  ƒ Z e d „  ƒ Z RS(   s.   Result that we know has already been executed.c         C@  s(   | |  _  | |  _ | |  _ | |  _ d  S(   N(   R(   t   _resultt   _statet
   _traceback(   R,   R(   t	   ret_valueRZ   R~   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR-   N  s    			c         C@  s,   i |  j  d 6|  j d 6|  j d 6|  j d 6S(   NR   R<   R;   R~   (   R(   RÂ   RÃ   RÄ   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRz   T  s    c         C@  s   |  j  |  j ƒ  f S(   N(   Rt   Rv   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRw   X  s    c         C@  s   |  j  |  j |  j |  j f S(   N(   R(   RÂ   RÃ   RÄ   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRv   [  s    c         C@  s   |  j  ƒ  \ } } | | Œ  S(   N(   Rw   (   R,   t   clst   args(    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRu   ^  s    c         C@  s   t  S(   N(   R   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRV   b  s    c         K@  sB   |  j  ƒ  r |  j S|  j t j k r> | r7 |  j ‚ n  |  j Sd  S(   N(   R]   R<   RZ   R   RD   (   R,   R4   RA   RM   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRF   e  s    c         C@  s   d  S(   N(    (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR/   n  s    c         O@  s   t  j |  _ d  S(   N(   R   t   REVOKEDRÃ   (   R,   RÇ   RM   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR6   q  s    c         C@  s   d j  |  ƒ S(   Ns   <EagerResult: {0.id}>(   Rl   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRn   t  s    c         C@  s   |  j  S(   s   The tasks return value(   RÂ   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR<   w  s    c         C@  s   |  j  S(   s   The tasks state.(   RÃ   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRZ   |  s    c         C@  s   |  j  S(   s!   The traceback if the task failed.(   RÄ   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR~   ‚  s    c         C@  s   t  S(   N(   R   (   R,   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyRy   ‡  s    N(   R"   R#   R$   R%   R*   R-   Rz   Rw   Rv   Ru   RV   R   RF   R7   R/   R6   Rn   R‚   R<   RZ   R;   R~   Ry   (    (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR   J  s$   								c         C@  s»   t  | ƒ } | j } t |  t ƒ s· |  \ } } | rb | j | g  | D] } t | | ƒ ^ qF ƒ St | t t f ƒ r} | n	 | d  f \ } } | r§ t | | ƒ } n  | | d | ƒS|  S(   NR&   (	   R
   R   Ro   R   R   R   RH   t   tupleR%   (   RŒ   R'   t   ResultR¯   t   nodesRT   R(   R&   (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyR   Œ  s    	&-(2   R$   t
   __future__R    R›   R   t   collectionsR   t
   contextlibR   R   t   kombu.utilsR   t   kombu.utils.compatR   t    R   R   RÃ   R   R	   R'   R
   t   datastructuresR   R   t
   exceptionsR   R   t   fiveR   R   R   R   t   utilsR   t   __all__R   R   R!   t   objectR   R   t   BaseAsyncResultR   R   R¾   R   R%   R   t   from_serializable(    (    (    s/   /tmp/pip-unpacked-wheel-gV1wwp/celery/result.pyt   <module>   s@   "		
ÿ Uÿ HNB