U
    Z+d	                     @   sv   d Z ddlmZ ddlmZmZmZmZmZ ddl	m
Z
 ddlmZ ddlmZ dZe
d	d
 ZdddZdd ZdS )zCelery Application.    )_state)app_or_defaultdisable_traceenable_tracepop_current_taskpush_current_task)Proxy   )Celery)
AppPickler)
r
   r   r   default_app	bugreportr   r   shared_taskr   r   c                   C   s   t jS N)r   r    r   r   7/tmp/pip-unpacked-wheel-ucduq0nd/celery/app/__init__.py<lambda>       r   Nc                 C   s   | p
t   S )z)Return information useful in bug reports.)r   get_current_appr   appr   r   r   r      s    r   c                  O   s<   dd }t | dkr2t| d r2|f || d S || |S )aL  Create shared task (decorator).

    This can be used by library authors to create tasks that'll work
    for any app environment.

    Returns:
        ~celery.local.Proxy: A proxy that always takes the task from the
        current apps task registry.

    Example:

        >>> from celery import Celery, shared_task
        >>> @shared_task
        ... def add(x, y):
        ...     return x + y
        ...
        >>> app1 = Celery(broker='amqp://')
        >>> add.app is app1
        True
        >>> app2 = Celery(broker='redis://')
        >>> add.app is app2
        True
    c                     s    fdd}|S )Nc              
      sh    dt fdd t D ]*}|jr&|j |j f W 5 Q R X q& fdd}t|S )Nnamec                    s   | j  fS r   )_task_from_funr   )funoptionsr   r   r   8   r   zJshared_task.<locals>.create_shared_task.<locals>.__inner.<locals>.<lambda>c                     s"   t  } | jp|  j j S r   )r   r   ZtasksZgen_task_name__name__
__module__r   r   r   r   r   task_by_consC   s    zNshared_task.<locals>.create_shared_task.<locals>.__inner.<locals>.task_by_cons)getr   Zconnect_on_app_finalizeZ_get_active_apps	finalizedZ_finalize_mutexr   r   )r   r   r   r   r   r   __inner3   s    
z8shared_task.<locals>.create_shared_task.<locals>.__innerr   )r   r"   r   r!   r   create_shared_task1   s    z'shared_task.<locals>.create_shared_taskr	   r   )lencallable)argskwargsr#   r   r   r   r      s    r   )N)__doc__Zceleryr   Zcelery._stater   r   r   r   r   Zcelery.localr   baser
   utilsr   __all__r   r   r   r   r   r   r   <module>   s   
