
P'^c           @@  s   d  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 e d d	 d
 d d d e f d     YZ d S(   s   
    celery.task.sets
    ~~~~~~~~~~~~~~~~

    Old ``group`` implementation, this module should
    not be used anymore use :func:`celery.group` instead.

i    (   t   absolute_import(   t   get_current_worker_task(   t   app_or_default(   t   maybe_signature(   t   uuidt   warn_deprecated(   t   subtasks   celery.task.sets and TaskSett   removals   4.0t   alternativesD   Please use "group" instead (see the Canvas section in the userguide)t   TaskSetc           B@  sw   e  Z d  Z d Z d d d d  Z d d d d  Z d   Z d d  Z d   Z	 e
 d    Z e j d    Z RS(	   s  A task containing several subtasks, making it possible
    to track how many, or when all of the tasks have been completed.

    :param tasks: A list of :class:`subtask` instances.

    Example::

        >>> from myproj.tasks import refresh_feed

        >>> urls = ('http://cnn.com/rss', 'http://bbc.co.uk/rss')
        >>> s = TaskSet(refresh_feed.s(url) for url in urls)
        >>> taskset_result = s.apply_async()
        >>> list_of_return_values = taskset_result.join()  # *expensive*

    c         @  so   t  | p   j    _ t t    j   f d   | p< g  D  | pV   j j j   _ t      _	 d  S(   Nc         3@  s$   |  ] } t  | d    j Vq d S(   t   appN(   R   R
   (   t   .0t   t(   t   self(    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/task/sets.pys	   <genexpr>/   s    (
   R   R
   t   superR	   t   __init__t   amqpt   TaskProducert	   Publishert   lent   total(   R   t   tasksR
   R   (    (   R   s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/task/sets.pyR   ,   s
    c         C@  s   |  j  } | j j r% |  j d |  S| j |  r } | pC t   } | pX |  j |  } |  j | |  } | j | |  }	 t	   }
 |
 r |
 j
 |	  n  |	 SWd QXd S(   s   Apply TaskSet.t
   taskset_idN(   R
   t   conft   CELERY_ALWAYS_EAGERt   applyt   connection_or_acquireR   R   t   _async_resultst   TaskSetResultR   t	   add_trail(   R   t
   connectiont	   publisherR   R
   t   connt   setidt   pubt   resultst   resultt   parent(    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/task/sets.pyt   apply_async4   s    		c         C@  s)   g  |  D] } | j  d | d |  ^ q S(   NR   R   (   R&   (   R   R   R   t   task(    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/task/sets.pyR   F   s    c         C@  s+   | p t    } |  j j | |  j |   S(   s?   Applies the TaskSet locally by blocking until all tasks return.(   R   R
   R   t   _sync_results(   R   R   R!   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/task/sets.pyR   J   s    c         C@  s#   g  |  D] } | j  d |  ^ q S(   NR   (   R   (   R   R   R'   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/task/sets.pyR(   O   s    c         C@  s   |  S(   N(    (   R   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/task/sets.pyR   R   s    c         C@  s   | |  (d  S(   N(    (   R   R   (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/task/sets.pyR   V   s    N(   t   __name__t
   __module__t   __doc__t   NoneR
   R   R&   R   R   R(   t   propertyR   t   setter(    (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/task/sets.pyR	      s   		N(   R+   t
   __future__R    t   celery._stateR   t
   celery.appR   t   celery.canvasR   t   celery.utilsR   R   R   t   listR	   (    (    (    s2   /tmp/pip-unpacked-wheel-gV1wwp/celery/task/sets.pyt   <module>	   s   