
P'^c           @@  s,  d  Z  d d l m 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 m Z m Z d d
 l m Z m Z m Z d d l m Z d d l m Z d d l m Z m Z m Z m Z d d l m Z 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 g Z, e d d d d d d d d d d  d! d"  Z- d# Z. d$ Z/ d% Z0 d& Z1 d' e2 f d(     YZ3 d) d*  Z4 e5 e5 d+  Z6 d e2 f d,     YZ7 d- e8 f d.     YZ9 e e9  d e2 f d/     Y Z: e: Z; d S(0   ss   
    celery.app.task
    ~~~~~~~~~~~~~~~

    Task Implementation: Task request context, and the base task class.

i    (   t   absolute_importN(   t   ExceptionInfo(   t   current_app(   t   states(   t   _task_stack(   t	   signature(   t   MaxRetriesExceededErrort   Rejectt   Retry(   t   class_propertyt   itemst   with_metaclass(   t   Proxy(   t   EagerResult(   t   gen_task_namet   fun_takes_kwargst   uuidt   maybe_reraise(   t   mattrgettert
   maybe_list(   t   instantiate(   t	   ErrorMaili   (   t   resolve_all(   t   _unpickle_task_v2(   t   appstrt   Contextt   Taskt   queuet   routing_keyt   exchanget   priorityt   expirest
   serializert   delivery_modet   compressiont
   time_limitt   soft_time_limitt	   immediatet	   mandatorys$   <class {0.__name__} of {app}{flags}>s   <unbound {0.__name__}{flags}>s,   <@task {0.name} bound to other {0.__self__}>s!   <@task: {0.name} of {app}{flags}>t   _CompatSharedc           B@  s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C@  s   | |  _  | |  _ d  S(   N(   t   namet   cons(   t   selfR(   R)   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   __init__2   s    	c         C@  s   t  |  j  S(   N(   t   hashR(   (   R*   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   __hash__6   s    c         C@  s   d |  j  f S(   Ns   <OldTask: %r>(   R(   (   R*   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   __repr__9   s    c         C@  s   |  j  |  S(   N(   R)   (   R*   t   app(    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   __call__<   s    (   t   __name__t
   __module__R+   R-   R.   R0   (    (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR'   0   s   			t    c         C@  s    |  r d j  d j |    S| S(   Ns    ({0})s   , (   t   formatt   join(   t   flagst   default(    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt	   _strflags@   s    c         C@  s   | d  k	 r t |  n g  } |  j r6 | j d  n d  | sX |  j rO t n t } n  | j |  d t |  d |  j r t	 |  j  n d  S(   Ns   v2 compatibleR6   R/   (
   t   Nonet   listt   __v2_compat__t   appendt   _appt   R_BOUND_TASKt   R_UNBOUND_TASKR4   R8   R   (   t   taskt   fmtR6   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt	   _reprtaskF   s    c           B@  s   e  Z d Z d Z d Z d Z d Z d Z d  Z	 d Z
 d Z e Z d Z d Z d Z d Z d Z d Z d Z d Z e Z d Z d Z d Z d Z d  Z d   Z d   Z d   Z d d  Z  d   Z! e" d    Z# RS(   i    c         O@  s   |  j  | |   d  S(   N(   t   update(   R*   t   argst   kwargs(    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR+   l   s    c         O@  s   |  j  j | |   S(   N(   t   __dict__RC   (   R*   RD   RE   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyRC   o   s    c         C@  s   |  j  j   S(   N(   RF   t   clear(   R*   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyRG   r   s    c         C@  s   t  |  | |  S(   N(   t   getattr(   R*   t   keyR7   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   getu   s    c         C@  s   d j  t |    S(   Ns   <Context: {0!r}>(   R4   t   vars(   R*   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR.   x   s    c         C@  s"   |  j  d  k r g  |  _  n  |  j  S(   N(   t	   _childrenR9   (   R*   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   children{   s    N($   R1   R2   R9   t   logfilet   loglevelt   hostnamet   idRD   RE   t   retriest   etaR   t   Falset   is_eagert   headerst   delivery_infot   reply_tot   correlation_idt   tasksett   groupt   chordt   utct   Truet   called_directlyt	   callbackst   errbackst	   timelimitRL   t
   _protectedR+   RC   RG   RJ   R.   t   propertyRM   (    (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR   Q   s<   				t   TaskTypec           B@  s&   e  Z d  Z i  Z d   Z d   Z RS(   s  Meta class for tasks.

    Automatically registers the task in the task registry (except
    if the :attr:`Task.abstract`` attribute is set).

    If no :attr:`Task.name` attribute is provided, then the name is generated
    from the module and class name.

    c         @  s  t  t   j }   j d  p$ d }   j d d   } | sR   j d t  re |       S  j d d   p   j d d   } t | t  r | d  k r x<  D]% } t	 | d d   r | j
 } Pq q Wt j   } n  |   d <  j d  }	 |	 s t |  |    d <}	 n    j d  sd	 d
 l m }
 d j |  g  } |  j k rd  j | <|
 t |      f d     qn  | j } |	 | k r| j |        n  | |	 } | j |  | j S(   NR2   t   __main__t   abstractt   autoregisterR=   R/   R(   t
   _decoratedi    (   t   connect_on_app_finalizet   .i   c         @  s"   t  j    t   d |   S(   NR=   (   Re   t   __new__t   dict(   R/   (   t   attrst   basest   clsR(   (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   <lambda>   s   (   t   superRe   Rl   RJ   t   popR9   R^   t
   isinstanceR   RH   R=   R   t   _get_current_objectR   t   celery._stateRj   R5   t   _creation_countR'   t   _taskst   registert   bindt	   __class__(   Rp   R(   Ro   Rn   t   newt   task_moduleRg   R/   t   baset	   task_nameRj   t   unique_namet   taskst   instance(    (   Rn   Ro   Rp   R(   s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyRl      s<    $	
"		
c         C@  s
   t  |   S(   N(   RB   (   Rp   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR.      s    (   R1   R2   t   __doc__Rw   Rl   R.   (    (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyRe      s   		=c           B@  s  e  Z d  Z d7 Z e Z e Z e Z d Z	 d7 Z
 d7 Z d7 Z e Z e Z d Z d8 Z d7 Z d7 Z e Z e Z d7 Z d7 Z d7 Z d7 Z d7 Z d7 Z e Z d7 Z d7 Z d9 Z d7 Z  d7 Z! d7 Z" e Z# d: d; d< d= d> d? d@ f Z$ d7 Z% e Z# e& d    Z' e& d    Z( e& d    Z) e* e) e'  Z+ e& d    Z, e& d    Z- d   Z. d   Z/ d   Z0 d   Z1 d   Z2 d7 d7 d7 d7 d7 d7 d  Z3 d7 d7 d7 d7 d  Z4 d7 d7 d7 e d7 d7 d7 d  Z5 d7 d7 d7 d7 d  Z6 d    Z7 d7 d!  Z8 d"   Z9 d#   Z: d$   Z; d%   Z< d&   Z= d'   Z> d7 d7 d7 d(  Z? d)   Z@ d*   ZA d+   ZB d,   ZC d-   ZD d.   ZE d/   ZF d0   ZG d1   ZH d2   ZI eJ eI  ZK d3   ZL eJ d4    Z e jM d5    Z eJ d6    Z  RS(A   s   Task base class.

    When called tasks apply the :meth:`run` method.  This method must
    be defined by all tasks (that is unless the :meth:`__call__` method
    is overridden).

    s   celery.worker.strategy:defaulti   i<   t   send_error_emailst   CELERY_SEND_TASK_ERROR_EMAILSR    t   CELERY_TASK_SERIALIZERt
   rate_limitt   CELERY_DEFAULT_RATE_LIMITt   track_startedt   CELERY_TRACK_STARTEDt	   acks_latet   CELERY_ACKS_LATEt   ignore_resultt   CELERY_IGNORE_RESULTt   store_errors_even_if_ignoredt#   CELERY_STORE_ERRORS_EVEN_IF_IGNOREDc         C@  s   |  j  t } |  _  | |  _ | j } d  |  _ xF |  j D]; \ } } t |  | d   d  k r8 t |  | | |  q8 q8 W|  j	 d  k r | j	 |  _	 n  | s |  j
   d d l m } |   |  _ n  |  j |  | S(   Ni    (   t
   LocalStack(   t	   __bound__R^   R=   t   confR9   t   _exec_optionst   from_configRH   t   setattrt   accept_magic_kwargst   annotatet   celery.utils.threadsR   t   request_stackt   on_bound(   R*   R/   t	   was_boundR   t	   attr_namet   config_nameR   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyRz   i  s    			
c         C@  s   d S(   sc   This method can be defined to do additional actions when the
        task class is bound to an app.N(    (   R*   R/   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR     s    c         C@  s>   |  j  d  k r t |  _  n  |  j s7 |  j |  j   n  |  j  S(   N(   R=   R9   R   R   Rz   (   R*   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   _get_app  s
    	c         C@  sw   xp t  |  j j |   D]Y } xP t |  D]B \ } } | j d  r[ |  j | d |  q) t |  | |  q) Wq Wd  S(   Nt   @i   (   t   resolve_all_annotationsR/   t   annotationsR
   t
   startswitht
   add_aroundR   (   R*   t   dRI   t   value(    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR     s
    c         C@  sV   t  |  |  } t  | d d   r- | j } n  | |  } | | _ t |  | |  d  S(   Nt   __wrapped__(   RH   R9   R   R   (   R*   t   attrt   aroundt   origt   meth(    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR     s    	c         O@  sl   t  j |   |  j   z9 |  j d  k	 r? |  j |  j | |  S|  j | |   SWd  |  j   t  j   Xd  S(   N(   R   t   pusht   push_requestt   __self__R9   t   runt   pop_requestRs   (   R*   RD   RE   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR0     s    

c         C@  sF   t  |   j } | r* | t j k r* | n d  } t |  j | f d  f S(   N(   t   typeR2   t   syst   modulesR9   R   R(   (   R*   t   mod(    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt
   __reduce__  s    !c         O@  s   t  d   d S(   s)   The body of the task executed by workers.s!   Tasks must define the run method.N(   t   NotImplementedError(   R*   RD   RE   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR     s    c         K@  s   t  |  j |  | | |  S(   N(   R   t   Strategy(   R*   R/   t   consumerRE   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   start_strategy  s    c         O@  s   |  j  | |  S(   sA  Star argument version of :meth:`apply_async`.

        Does not support the extra options enabled by :meth:`apply_async`.

        :param \*args: positional arguments passed on to the task.
        :param \*\*kwargs: keyword arguments passed on to the task.

        :returns :class:`celery.result.AsyncResult`:

        (   t   apply_async(   R*   RD   RE   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   delay  s    c   	      K@  s   |  j    } | j j rF |  j | | d | p3 t   d | d | | S|  j d k	 r t | t  rj | n t | pv d  } |  j f | } n  | j	 |  j
 | | d | d | d | d | d |  j t |  j   |  S(   s  Apply tasks asynchronously by sending a message.

        :keyword args: The positional arguments to pass on to the
                       task (a :class:`list` or :class:`tuple`).

        :keyword kwargs: The keyword arguments to pass on to the
                         task (a :class:`dict`)

        :keyword countdown: Number of seconds into the future that the
                            task should execute. Defaults to immediate
                            execution.

        :keyword eta: A :class:`~datetime.datetime` object describing
                      the absolute time and date of when the task should
                      be executed.  May not be specified if `countdown`
                      is also supplied.

        :keyword expires: Either a :class:`int`, describing the number of
                          seconds, or a :class:`~datetime.datetime` object
                          that describes the absolute time and date of when
                          the task should expire.  The task will not be
                          executed after the expiration time.

        :keyword connection: Re-use existing broker connection instead
                             of establishing a new one.

        :keyword retry: If enabled sending of the task message will be retried
                        in the event of connection loss or failure.  Default
                        is taken from the :setting:`CELERY_TASK_PUBLISH_RETRY`
                        setting.  Note that you need to handle the
                        producer/connection manually for this to work.

        :keyword retry_policy:  Override the retry policy used.  See the
                                :setting:`CELERY_TASK_PUBLISH_RETRY_POLICY`
                                setting.

        :keyword routing_key: Custom routing key used to route the task to a
                              worker server. If in combination with a
                              ``queue`` argument only used to specify custom
                              routing keys to topic exchanges.

        :keyword queue: The queue to route the task to.  This must be a key
                        present in :setting:`CELERY_QUEUES`, or
                        :setting:`CELERY_CREATE_MISSING_QUEUES` must be
                        enabled.  See :ref:`guide-routing` for more
                        information.

        :keyword exchange: Named custom exchange to send the task to.
                           Usually not used in combination with the ``queue``
                           argument.

        :keyword priority: The task priority, a number between 0 and 9.
                           Defaults to the :attr:`priority` attribute.

        :keyword serializer: A string identifying the default
                             serialization method to use.  Can be `pickle`,
                             `json`, `yaml`, `msgpack` or any custom
                             serialization method that has been registered
                             with :mod:`kombu.serialization.registry`.
                             Defaults to the :attr:`serializer` attribute.

        :keyword compression: A string identifying the compression method
                              to use.  Can be one of ``zlib``, ``bzip2``,
                              or any custom compression methods registered with
                              :func:`kombu.compression.register`. Defaults to
                              the :setting:`CELERY_MESSAGE_COMPRESSION`
                              setting.
        :keyword link: A single, or a list of tasks to apply if the
                       task exits successfully.
        :keyword link_error: A single, or a list of tasks to apply
                      if an error occurs while executing the task.

        :keyword producer: :class:~@amqp.TaskProducer` instance to use.

        :keyword add_to_parent: If set to True (default) and the task
            is applied while executing another task, then the result
            will be appended to the parent tasks ``request.children``
            attribute.  Trailing can also be disabled by default using the
            :attr:`trail` attribute

        :keyword publisher: Deprecated alias to ``producer``.

        :keyword headers: Message headers to be sent in the
            task (a :class:`dict`)

        :rtype :class:`celery.result.AsyncResult`: if
            :setting:`CELERY_ALWAYS_EAGER` is not set, otherwise
            :class:`celery.result.EagerResult`.

        Also supports all keyword arguments supported by
        :meth:`kombu.Producer.publish`.

        .. note::
            If the :setting:`CELERY_ALWAYS_EAGER` setting is set, it will
            be replaced by a local :func:`apply` call instead.

        t   task_idt   linkt
   link_errort   producert
   result_clsN(    (   R   R   t   CELERY_ALWAYS_EAGERt   applyR   R   R9   Rt   t   tuplet	   send_taskR(   t   AsyncResultRm   t   _get_exec_options(	   R*   RD   RE   R   R   R   R   t   optionsR/   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR     s    c'c   	      K@  s  | d  k r |  j n | } | d  k r0 | j n | } | d  k rK | j n | } | j p] d \ } } i	 | j d 6| j d 6| j d 6| j d 6| j	 d 6| d 6| d 6| j
 d 6| j d	 6} | j | r i | d
 6n | j p i   |  j | | | d |  | S(   NR   R   R   t   group_idR\   R$   R#   RX   RV   R   R   (   NN(   R9   t   requestRD   RE   Rb   RQ   R`   Ra   R[   R\   RX   RV   RC   RW   t   subtask(	   R*   R   RD   RE   R   t   extra_optionst
   limit_hardt
   limit_softR   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   subtask_from_request@  s"    





#c         K@  s  |  j  }	 |	 j d }
 | d
 k r+ |  j n | } |	 j rY t   | pS t d d
   n  | rx | d
 k rx |  j } n  |	 j } |  j	 |	 | | d | d | d |
 | } | d
 k	 r	|
 | k r	| r t   |  n  |  j
 d j |  j |	 j | j | j    n  t d | d | p|  } | r>| j   j   | Sy | j   Wn% t k
 rs} t | d	 t  n X| r|  n  | S(   sh  Retry the task.

        :param args: Positional arguments to retry with.
        :param kwargs: Keyword arguments to retry with.
        :keyword exc: Custom exception to report when the max restart
            limit has been exceeded (default:
            :exc:`~@MaxRetriesExceededError`).

            If this argument is set and retry is called while
            an exception was raised (``sys.exc_info()`` is set)
            it will attempt to reraise the current exception.

            If no exception was raised it will raise the ``exc``
            argument provided.
        :keyword countdown: Time in seconds to delay the retry for.
        :keyword eta: Explicit time and date to run the retry at
                      (must be a :class:`~datetime.datetime` instance).
        :keyword max_retries: If set, overrides the default retry limit for
            this execution. Changes to this parameter do not propagate to
            subsequent task retry attempts. A value of :const:`None`, means
            "use the default", so if you want infinite retries you would
            have to set the :attr:`max_retries` attribute of the task to
            :const:`None` first.
        :keyword time_limit: If set, overrides the default time limit.
        :keyword soft_time_limit: If set, overrides the default soft
                                  time limit.
        :keyword \*\*options: Any extra options to pass on to
                              meth:`apply_async`.
        :keyword throw: If this is :const:`False`, do not raise the
                        :exc:`~@Retry` exception,
                        that tells the worker to mark the task as being
                        retried.  Note that this means the task will be
                        marked as failed if the task raises an exception,
                        or successful if it returns.

        :raises celery.exceptions.Retry: To tell the worker that
            the task has been re-sent for retry. This always happens,
            unless the `throw` keyword argument has been explicitly set
            to :const:`False`, and is considered normal operation.

        **Example**

        .. code-block:: python

            >>> from imaginary_twitter_lib import Twitter
            >>> from proj.celery import app

            >>> @app.task(bind=True)
            ... def tweet(self, auth, message):
            ...     twitter = Twitter(oauth=auth)
            ...     try:
            ...         twitter.post_status_update(message)
            ...     except twitter.FailWhale as exc:
            ...         # Retry in 5 minutes.
            ...         raise self.retry(countdown=60 * 5, exc=exc)

        Although the task will never return above as `retry` raises an
        exception to notify the worker, we use `raise` in front of the retry
        to convey that the rest of the block will not be executed.

        i   s   Task can be retriedt	   countdownRS   RR   s(   Can't retry {0}[{1}] args:{2} kwargs:{3}t   exct   whent   requeueN(   R   RR   R9   t   max_retriesR_   R   R   t   default_retry_delayRU   R   R   R4   R(   RQ   RD   RE   R   RJ   R   t	   ExceptionR   RT   (   R*   RD   RE   R   t   throwRS   R   R   R   R   RR   RU   t   St   ret(    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   retryV  s>    ?					$	c         @  s_  d d l  m } |  j   } | p% d } |  j d k	 rP |  j f t |  } n  | pY i  } | j d  pq t   } | j d d  }	 | j d | j	 d d   }
 | j
 |  j } i	 | d 6|	 d 6t d 6| j d	  d	 6| j d
 d  d
 6t |  d 6t |  d 6| j d  d 6i t d 6d 6} |  j ri | j d 6| d 6|	 d 6t d 6| j d	  d	 6| j d
 d  d
 6i t d 6d 6} t | j |    t   f d   t |  D  } | j |  n  d } | | | | | d |  j   d | d |
 \ } } t | t  r+| j | j } } n  | d k r@t j n | j } t | | | d | S(   s  Execute this task locally, by blocking until the task returns.

        :param args: positional arguments passed on to the task.
        :param kwargs: keyword arguments passed on to the task.
        :keyword throw: Re-raise task exceptions.  Defaults to
                        the :setting:`CELERY_EAGER_PROPAGATES_EXCEPTIONS`
                        setting.

        :rtype :class:`celery.result.EagerResult`:

        i    (   t   eager_trace_taskR   RR   t"   CELERY_EAGER_PROPAGATES_EXCEPTIONSR   RQ   RU   RN   RO   R`   Ra   RV   RW   R   t   task_retriest   task_is_eagerc         3@  s-   |  ]# \ } } |   k r | | f Vq d  S(   N(    (   t   .0RI   t   val(   t   supported_keys(    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pys	   <genexpr>  s   	R/   R   t	   propagatet	   traceback(    N(   t   celery.app.traceR   R   R   R9   R   RJ   R   t   eitherRs   Rx   R(   R^   R   R   R   R   Rm   R
   RC   Rt   R   t	   exceptionR   R   t   SUCCESSt   stateR   (   R*   RD   RE   R   R   R   R   R/   R   RR   R   R@   R   t   default_kwargst   extend_witht   tbt   retvalt   infoR   (    (   R   s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR     sP    	
	c         K@  s(   |  j    j | d |  j d |  j | S(   sm   Get AsyncResult instance for this kind of task.

        :param task_id: Task id to get result for.

        t   backendR   (   R   R   R   R(   (   R*   R   RE   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR     s    c         O@  s&   | j  d |  j  t |  | | |  S(   s   Return :class:`~celery.signature` object for
        this task, wrapping arguments and execution options
        for a single task invocation.R/   (   t
   setdefaultR/   R   (   R*   RD   t   starargst
   starkwargs(    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR   
  s    c         O@  s   |  j  | |  S(   s!   ``.s(*a, **k) -> .subtask(a, k)``(   R   (   R*   RD   RE   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   s  s    c         O@  s   |  j  | | d t S(   s2   ``.si(*a, **k) -> .subtask(a, k, immutable=True)``t	   immutable(   R   R^   (   R*   RD   RE   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   si  s    c         C@  s/   d d l  m } | |  j   | | d |  j S(   s<   Creates a :class:`~celery.canvas.chunks` task for this task.i    (   t   chunksR/   (   t   celeryR   R   R/   (   R*   t   itt   nR   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR     s    c         C@  s,   d d l  m } | |  j   | d |  j S(   s8   Creates a :class:`~celery.canvas.xmap` task from ``it``.i    (   t   xmapR/   (   R   R   R   R/   (   R*   R   R   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   map  s    c         C@  s,   d d l  m } | |  j   | d |  j S(   s<   Creates a :class:`~celery.canvas.xstarmap` task from ``it``.i    (   t   xstarmapR/   (   R   R   R   R/   (   R*   R   R   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   starmap#  s    c      	   K@  sJ   |  j  } |  j j j d | j    } | j | d | j | SWd  QXd  S(   NRP   R   (   R   R/   t   eventst   default_dispatcherRP   t   sendRQ   (   R*   t   type_t   fieldst   reqR   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt
   send_event(  s    	c         C@  s5   | d k r |  j j } n  |  j j | | |  d S(   s   Update task state.

        :keyword task_id: Id of the task to update, defaults to the
                          id of the current task
        :keyword state: New state (:class:`str`).
        :keyword meta: State metadata (:class:`dict`).



        N(   R9   R   RQ   R   t   store_result(   R*   R   R   t   meta(    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   update_state-  s    c         C@  s   d S(   s  Success handler.

        Run by the worker if the task executes successfully.

        :param retval: The return value of the task.
        :param task_id: Unique id of the executed task.
        :param args: Original arguments for the executed task.
        :param kwargs: Original keyword arguments for the executed task.

        The return value of this handler is ignored.

        N(    (   R*   R   R   RD   RE   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt
   on_success<  s    c         C@  s   d S(   s  Retry handler.

        This is run by the worker when the task is to be retried.

        :param exc: The exception sent to :meth:`retry`.
        :param task_id: Unique id of the retried task.
        :param args: Original arguments for the retried task.
        :param kwargs: Original keyword arguments for the retried task.

        :keyword einfo: :class:`~billiard.einfo.ExceptionInfo`
                        instance, containing the traceback.

        The return value of this handler is ignored.

        N(    (   R*   R   R   RD   RE   t   einfo(    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   on_retryK  s    c         C@  s   d S(   s  Error handler.

        This is run by the worker when the task fails.

        :param exc: The exception raised by the task.
        :param task_id: Unique id of the failed task.
        :param args: Original arguments for the task that failed.
        :param kwargs: Original keyword arguments for the task
                       that failed.

        :keyword einfo: :class:`~billiard.einfo.ExceptionInfo`
                        instance, containing the traceback.

        The return value of this handler is ignored.

        N(    (   R*   R   R   RD   RE   R  (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt
   on_failure]  s    c         C@  s   d S(   s  Handler called after the task returns.

        :param status: Current task state.
        :param retval: Task return value/exception.
        :param task_id: Unique id of the task.
        :param args: Original arguments for the task.
        :param kwargs: Original keyword arguments for the task.

        :keyword einfo: :class:`~billiard.einfo.ExceptionInfo`
                        instance, containing the traceback (if any).

        The return value of this handler is ignored.

        N(    (   R*   t   statusR   R   RD   RE   R  (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   after_returnp  s    c         K@  s?   |  j  r; t |  d d   r; |  j |  |  j | |  n  d  S(   Nt   disable_error_emails(   R   RH   R9   R   R   (   R*   t   contextR   RE   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   send_error_email  s    	c         C@  s#   |  j  r |  j j j |  n  | S(   N(   t   trailR   RM   R<   (   R*   t   result(    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt	   add_trail  s    	c         O@  s   |  j  j t | |    d  S(   N(   R   R   R   (   R*   RD   RE   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR     s    c         C@  s   |  j  j   d  S(   N(   R   Rs   (   R*   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR     s    c         C@  s   t  |  |  j r t n t  S(   s   `repr(task)`(   RB   R   t   R_SELF_TASKt
   R_INSTANCE(   R*   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR.     s    c         C@  sA   |  j  j } | d k r= |  j d k r6 t   |  _ n  |  j S| S(   s   Get current request object.N(   R   t   topR9   t   _default_requestR   (   R*   R  (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   _get_request  s    c         C@  s(   |  j  d  k r! t |   |  _  n  |  j  S(   N(   R   R9   t   extract_exec_options(   R*   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR     s    c         C@  s#   |  j  } | d  k r |  j j S| S(   N(   t   _backendR9   R/   R   (   R*   R   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR     s    	
c         C@  s   | |  _  d  S(   N(   R  (   R*   R   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR     s    c         C@  s
   |  j  j S(   N(   R{   R1   (   R*   (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR1     s    Ni   (    (   R   R   (   R    R   (   R   R   (   R   R   (   R   R   (   R   R   (   R   R   (N   R1   R2   R   R9   t	   __trace__RT   R;   R   R   R   R   R=   R(   R^   Rg   R   R   R   R   R   R  t   send_eventsR   R   R    R#   R$   R   Rh   R   R   t   throwsR   R  R   R   R   R  t   classmethodRz   R   R   R	   R/   R   R   R0   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R  R  R  R  R	  R  R  R  R   R   R.   R  Rd   R   R   t   setter(    (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyR      s    						
			p	l=																		
	(<   R   t
   __future__R    R   t   billiard.einfoR   R   R   R   Rv   R   t   celery.canvasR   t   celery.exceptionsR   R   R   t   celery.fiveR	   R
   R   t   celery.localR   t   celery.resultR   t   celery.utilsR   R   R   R   t   celery.utils.functionalR   R   t   celery.utils.importsR   t   celery.utils.mailR   R   R   R   t   registryR   t   utilsR   t   __all__R  R>   R?   R  R  t   objectR'   R8   R9   RB   R   R   Re   R   t   BaseTask(    (    (    s1   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/task.pyt   <module>   sJ   "2M  