
     h7                        d 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 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! ddl"m#Z# ddl"m$Z% ddl"m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+ ddl,m-Z- ddl.m/Z/m0Z0 dZ1d Z2d Z3ej4        j5         G d de6                      Z7d Z8e79                    d           G d d e7                      Z: G d! de:          Z; G d" d#e7          Z<e79                                 G d$ d%e<                      Z=e79                                 G d& d'e<                      Z>e79                                 G d( d)e7                      Z$d* Z?e79                                 G d+ d,e7                      Z@e79                    d-           G d. d/e7                      ZAeAZBd0 ZCeCZDd3d2ZEeEZFdS )4zmComposing task work-flows.

.. seealso:

    You should import these from :mod:`celery` and not this module.
    N)deque)MutableSequence)deepcopy)partial)reduce)
itemgetter)GeneratorType)fxrangereprcall)cached_property)uuid)barrier)current_app)GroupResultallow_join_result)abstractChainMap)_regen)chunks)is_list	lookahead
maybe_listregenseq_concat_itemseq_concat_seq)getitem_property)remove_repeating_from_tasktruncate)		Signaturechainxmapxstarmapr   groupchord	signaturemaybe_signaturec                 $   	 t          | j                  }|dk    r| j        d         n| S # t          $ rZ 	 | j                                        }|dk    rt	          | j                  d         n| cY S # t
          t          f$ r | cY cY S w xY ww xY w)z"Unroll group with only one member.   r   )lentasks	TypeError__length_hint__listAttributeError)r$   sizes     I/var/www/html/Sam_Eipo/venv/lib/python3.11/site-packages/celery/canvas.pymaybe_unroll_groupr2   (   s    
65; "&u{1~~5  @ @ @	@;..00D ,01994$$Q''%??? 	* 	 	 	LLLLL	@s,   + 
BA3"B3BB
BBc                 $    t          | d|           S )Nname)getattrtasks    r1   task_name_fromr8   8   s    4&&&    c                   r    e Zd ZdZi ZdxZZdhZed:d            Z	ed:d            Z
	 	 	 d; fd	Zd Zd	 Zd<d
Zd=dZd>dZd<dZeZ	 	 d?dZeZd=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 Z#d Z$d Z%d  Z&d! Z' fd"Z(e)d#             Z*e+d$             Z,e+d%             Z-e+d&             Z.e+d'             Z/ e0d(d)          Z1 e0d*d+          Z2 e0d,d-          Z3 e0d.d/          Z4 e0d0d1          Z5 e0d2d3          Z6 e0d4d5          Z7 e0d6d7          Z8 e0d8d9          Z9 xZ:S )@r    a.  Task Signature.

    Class that wraps the arguments and execution options
    for a single task invocation.

    Used as the parts in a :class:`group` and other constructs,
    or to pass tasks around as callbacks while being compatible
    with serializers with a strict type subset.

    Signatures can also be created from tasks:

    - Using the ``.signature()`` method that has the same signature
      as ``Task.apply_async``:

        .. code-block:: pycon

            >>> add.signature(args=(1,), kwargs={'kw': 2}, options={})

    - or the ``.s()`` shortcut that works for star arguments:

        .. code-block:: pycon

            >>> add.s(1, kw=2)

    - the ``.s()`` shortcut does not allow you to specify execution options
      but there's a chaning `.set` method that returns the signature:

        .. code-block:: pycon

            >>> add.s(2, 2).set(countdown=10).set(expires=30).delay()

    Note:
        You should use :func:`~celery.signature` to create new signatures.
        The ``Signature`` class is the type returned by that function and
        should be used for ``isinstance`` checks for signatures.

    See Also:
        :ref:`guide-canvas` for the complete guide.

    Arguments:
        task (Union[Type[celery.app.task.Task], str]): Either a task
            class/instance, or the name of a task.
        args (Tuple): Positional arguments to apply.
        kwargs (Dict): Keyword arguments to apply.
        options (Dict): Additional options to :meth:`Task.apply_async`.

    Note:
        If the first argument is a :class:`dict`, the other
        arguments will be ignored and the values in the dict will be used
        instead::

            >>> s = signature('tasks.add', args=(2, 2))
            >>> signature(s)
            {'task': 'tasks.add', args=(2, 2), kwargs={}, options={}}
    Ngroup_idc                       fd}|S )Nc                 *    | j         p| j        <   | S N)TYPES__name__)subclassclsr4   s    r1   _innerz'Signature.register_type.<locals>._inner~   s    3;CId/h/0Or9    )rB   r4   rC   s   `` r1   register_typezSignature.register_type|   s)    	 	 	 	 	 	 r9   c                     |                     d          }|r(| j        |         }|| ur|                    ||          S t          ||          S )Nsubtask_typeapp)getr?   	from_dictr    )rB   drI   typ
target_clss        r1   rK   zSignature.from_dict   s]    eeN## 	83J$$!++A3+777$$$$r9   Fc	           
      T   || _         t          |t                    r#t                                          |           d S 	 |j        }
|| _        n# t          $ r |}
Y nw xY wt                                          |
t          |pd          |pi t          |pi fi |	||           d S )NrD   r7   argskwargsoptionsrG   	immutable)	_app
isinstancedictsuper__init__r4   _typer/   tuple)selfr7   rQ   rR   rS   typerG   rT   rI   ex	task_name	__class__s              r1   rY   zSignature.__init__   s     	dD!! 	GGT"""""" I	 "

 " ! ! ! 			!
 GGU4:2%6%6|W]11b11)#      s   A A A c                 R    |                      ||d          \  }}} | j        |i |S )z0Call the task directly (in the current process).N)_merger]   )r\   partial_argspartial_kwargsrQ   rR   _s         r1   __call__zSignature.__call__   s4    ++lNDIIfaty$)&)))r9   c                 .    |                      ||          S )z5Shortcut to :meth:`apply_async` using star arguments.apply_async)r\   rc   rd   s      r1   delayzSignature.delay   s    n===r9   c                     |r|nd}|r|ni }d |                                 D             }|                     |||          \  }}} | j        j        ||fi |S )zCall task locally.

        Same as :meth:`apply_async` but executed the task inline instead
        of sending a task message.
        rD   c                     i | ]
\  }}|||S r>   rD   .0kvs      r1   
<dictcomp>z#Signature.apply.<locals>.<dictcomp>       EEEDAqq}1a}}}r9   )itemsrb   r]   apply)r\   rQ   rR   rS   s       r1   rt   zSignature.apply   su     #tt!)rEEGMMOOEEE $D&' B BfgtytV77w777r9   c                    |r|nd}|r|ni }d |                                 D             }	 | j        }n# t          $ r Y dS w xY w|s|s|r|                     |||          \  }}}n| j        | j        | j        }}} |||fi |S )a  Apply this task asynchronously.

        Arguments:
            args (Tuple): Partial args to be prepended to the existing args.
            kwargs (Dict): Partial kwargs to be merged with existing kwargs.
            options (Dict): Partial options to be merged
                with existing options.

        Returns:
            ~@AsyncResult: promise of future evaluation.

        See also:
            :meth:`~@Task.apply_async` and the :ref:`guide-calling` guide.
        rD   c                     i | ]
\  }}|||S r>   rD   rm   s      r1   rq   z)Signature.apply_async.<locals>.<dictcomp>   rr   r9   N)rs   _apply_async
IndexErrorrb   rQ   rR   rS   )r\   rQ   rR   
route_namerS   _applys         r1   ri   zSignature.apply_async   s     #tt!)rEEGMMOOEEE	&FF 	 	 	FF	  	I6 	IW 	I$(KKfg$F$F!D&''$(It{DL'&D vdF..g...s   4 
AAc                 R    |r|nd}|r|ni }|1t           j        fi  fd|                                D             }n j        } j        r|s j         j        |fS |r$t          |          t           j                  z   n j        |rt           j        fi |n j        |fS )NrD   c                 @    i | ]\  }}|j         vs	|j        v||S rD   )_IMMUTABLE_OPTIONSrS   )rn   ro   rp   r\   s      r1   rq   z$Signature._merge.<locals>.<dictcomp>   sC     0 0 0AD333q7L7L 17L7L7Lr9   )rW   rS   rs   rT   rQ   rR   r[   )r\   rQ   rR   rS   forcenew_optionss   `     r1   rb   zSignature._merge   s    #tt!)r
 t|   0 0 0 0!(0 0 0  KK
 ,K> 	9% 	9It{K8826EdeDI....DI/5FT[++F+++4; 	r9   c           	      F   |r|nd}|r|ni }|s|s|r|                      |||          \  }}}n| j        | j        | j        }}}t                              | j        t          |          |t          |          | j	        | j
        d| j                  }| j        |_        |S )a7  Create a copy of this signature.

        Arguments:
            args (Tuple): Partial args to be prepended to the existing args.
            kwargs (Dict): Partial kwargs to be merged with existing kwargs.
            options (Dict): Partial options to be merged with
                existing options.
        rD   rP   rH   )rb   rQ   rR   rS   r    rK   r7   r[   r   rG   rT   rU   rZ   )r\   rQ   rR   optsr&   s        r1   clonezSignature.clone   s     #tt!)r 	F6 	FT 	F!%T64!@!@D&$$!%DK$&D''16t394<TNN9=9J6:n)F )F -1I ( 7 7	 *	r9   c                    | j         }	 |d         }n%# t          $ r |pt                      x}|d<   Y nw xY w|r||d<   |r||d<   d|vr| j        j        |d<   |r	d|vr||d<   |r||d<   |||d<   |                     |          S )	a6  Finalize the signature by adding a concrete task id.

        The task won't be called and you shouldn't call the signature
        twice after freezing it as that'll result in two task messages
        using the same task id.

        Returns:
            ~@AsyncResult: promise of future evaluation.
        task_idroot_id	parent_idreply_tor;   r%   Ngroup_index)rS   KeyErrorr   rI   
thread_oidAsyncResult)	r\   _idr;   r%   r   r   r   r   tids	            r1   freezezSignature.freeze  s     |	2y/CC 	2 	2 	2$'M4661C$y///	2  	&%DO 	* )DT!!#x2D 	(
$..'D 	"!DM""-D $$$    44c                 d    |                                  }|||_        |||_        |||_        |S )zReplace the args, kwargs or options set for this signature.

        These are only replaced if the argument for the section is
        not :const:`None`.
        )r   rQ   rR   rS   )r\   rQ   rR   rS   r&   s        r1   replacezSignature.replace4  s@     JJLL	!IN%I 'Ir9   c                 h    ||                      |           | j                            |           | S )u   Set arbitrary execution options (same as ``.options.update(…)``).

        Returns:
            Signature: This is a chaining method call
                (i.e., it will return ``self``).
        )set_immutablerS   update)r\   rT   rS   s      r1   setzSignature.setC  s9      y)))G$$$r9   c                     || _         d S r>   rT   )r\   rT   s     r1   r   zSignature.set_immutableO  s    "r9   c                     | j                             |g           }t          |t                    s|gx}| j         |<   |S r>   )rS   
setdefaultrV   r   )r\   keyrs   s      r1   _with_list_optionzSignature._with_list_optionR  sC    ''R00%11 	0)./EDL%r9   c                 b    |                      |          }||vr|                    |           |S r>   )r   appendr\   r   valuers   s       r1   append_to_list_optionzSignature.append_to_list_optionX  s7    &&s++LLr9   c                 t    |                      |          }|                    t          |                     d S r>   )r   extendr   r   s       r1   extend_list_optionzSignature.extend_list_option^  s5    &&s++Z&&'''''r9   c                 .    |                      d|          S )zAdd callback task to be applied if this task succeeds.

        Returns:
            Signature: the argument passed, for chaining
                or use with :func:`~functools.reduce`.
        linkr   r\   callbacks     r1   r   zSignature.linkb  s     ))&(;;;r9   c                 .    |                      d|          S )zAdd callback task to be applied on error in task execution.

        Returns:
            Signature: the argument passed, for chaining
                or use with :func:`~functools.reduce`.
        
link_errorr   r\   errbacks     r1   r   zSignature.link_errork  s     )),@@@r9   c                 0    |                      |           | S )a2  Version of :meth:`link_error` that supports chaining.

        on_error chains the original signature, not the errback so::

            >>> add.s(2, 2).on_error(errback.s()).delay()

        calls the ``add`` task, not the ``errback`` task, but the
        reverse is true for :meth:`link_error`.
        r   r   s     r1   on_errorzSignature.on_errort  s     	   r9   c                     t          t          j                            t          j        | ggd t	          | j                            d                    pg D                                           S )zhReturn a recursive list of dependencies.

        "unchain" if you will, but with links intact.
        c              3   >   K   | ]}|                                 V  d S r>   )flatten_links)rn   r   s     r1   	<genexpr>z*Signature.flatten_links.<locals>.<genexpr>  sJ       E E !! E E E E E Er9   r   )r.   	itertoolsr!   from_iterabler   rS   rJ   r\   s    r1   r   zSignature.flatten_links  s}    
 IO11)/VHE E#DL$4$4V$<$<==CE E E3
 3
     	r9   c                 v   t          |t                    r7t          t          | f|                                          | j                  S t          |t
                    r&t          |          }t          | || j                  S t          |t                    rt          | || j                  S t          S NrH   )
rV   _chainr   unchain_tasksrU   r$   r2   rI   r    NotImplementedr\   others     r1   __or__zSignature.__or__  s    eV$$ 	6.,,..0 059Y@ @ @ @u%% 	6&u--E$484444y)) 	6$495555r9   c                 ,    |                      |          S r>   )r   r   s     r1   __ior__zSignature.__ior__  s     {{5!!!r9   c           
         | j         }|j        }| j                            d          pt	                      }|                    d           5 }|j                            ||          }|j        	                    |d | j
        dd|i||j                   |                    |          cd d d            S # 1 swxY w Y   d S )Nr   r7   )
connectionrD   )r]   rI   rS   rJ   r   producer_or_acquirebackendon_task_callcontrolelectionr   r   r   )r\   r]   rI   r   producerpropss         r1   r   zSignature.election  s   yhly))3TVV$$T** 	)hL--h<<EK  f!+!A!AC!A5!A!A,4,? ! A A A ##C((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   A B99B= B=c                 j    |                      ||i d          \  }}}t          | d         ||          S )NT)r~   r7   )rb   r   )r\   rQ   rR   re   s       r1   r   zSignature.reprcall  s7    ++dFBd+CCfaVdF333r9   c                 D    | |t          |           <   t          |           S r>   )idrW   )r\   memos     r1   __deepcopy__zSignature.__deepcopy__  s    RXXDzzr9   c                 N    |                                                                  S r>   )ri   rJ   r   s    r1   
__invert__zSignature.__invert__  s     !!%%'''r9   c                 0    t           t          |           ffS r>   )r&   rW   r   s    r1   
__reduce__zSignature.__reduce__  s     4::-''r9   c                      t          |           S r>   )rW   r   s    r1   __json__zSignature.__json__  s    Dzzr9   c                 *    |                                  S r>   )r   r   s    r1   __repr__zSignature.__repr__  s    }}r9   c              #      K   t                                                      D ]4\  }}t          |t                    r|                                n||fV  5d S r>   )rX   rs   rV   bytesdecode)r\   ro   rp   r`   s      r1   rs   zSignature.items  s_      GGMMOO 	? 	?DAq *1e 4 4;!((***!Q>>>>>	? 	?r9   c                     | j         S r>   r6   r   s    r1   r4   zSignature.name  s     yr9   c                 @    | j         p| j        j        | d                  S Nr7   )rZ   rI   r+   r   s    r1   r]   zSignature.type  s    z9TX^DL99r9   c                     | j         pt          S r>   )rU   r   r   s    r1   rI   zSignature.app  s    y'K'r9   c                 T    	 | j         j        S # t          $ r | j        j        cY S w xY wr>   )r]   r   r   rI   r   s    r1   r   zSignature.AsyncResult  s>    	(9(( 	( 	( 	(8''''	(s    ''c                 |    	 | j         j        S # t          $ r# t          | j        j        | d                   cY S w xY wr   )r]   ri   r   _partialrI   	send_taskr   s    r1   rw   zSignature._apply_async  sL    	>9(( 	> 	> 	>DH.V=====	>s    *;;zoptions.task_idz	Task UUIDzoptions.parent_idzTask parent UUID.zoptions.root_idzTask root UUID.r7   zName of task.rQ   zPositional arguments to task.rR   zKeyword arguments to task.rS   zTask execution options.rG   zType of signaturerT   z+Flag set if no longer accepts new argumentsr>   )NNNNNNFNNN)NNN)NNNFNNNNNN);r@   
__module____qualname____doc__r?   rU   rZ   r}   classmethodrE   rK   rY   rf   rj   rt   ri   rb   r   r   r   _freezer   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rs   propertyr4   r   r]   rI   r   rw   r   r   r   r   r7   rQ   rR   rS   rG   rT   __classcell__r`   s   @r1   r    r    <   s       6 6p ED5 %   [ % % % [% CG9>     0* * *
> > >8 8 8 8/ / / /B   (   4 G489=#% #% #% #%J G   
 
 
 
# # #    ( ( (< < <A A A  	 	 	  " " "
) 
) 
)4 4 4  ( ( (( ( (
    ? ? ? ? ?   X : : _: ( ( _( ( ( _( > > _> 
	+[	9	9B  !46IJJI02CDDGFO44DF$CDDDh(DEEFy*CDDG##N4GHHL  BD DIIIIIr9   r    c                     |rt          dd i|           S d| vrt          d|i|           S |t          d| d         |z   i|           S d S )Nr!   r   )rS   r+   use_links      r1   _prepare_chain_from_optionsr     sw    R  !$111			%('222		 ''"2U":;! ! 	! 
	r9   r!   )r4   c            
            e Zd Z edd          Zedd            Z fdZd Zd Z	 fdZ
d	 Zdd
Z	 	 	 	 ddZ	 	 ddZddddddddej        df
dZddZed             Zd Z xZS )r   kwargs.taskszTasks in chain.Nc                     |d         d         }|r=t          |t                    rt          |          x}|d         d<   fd|D             }t          |fdi|d         S )NrR   r+   c                 2    g | ]}t          |           S rH   r'   rn   r7   rI   s     r1   
<listcomp>z$_chain.from_dict.<locals>.<listcomp>1  s&    FFF_Ts333FFFr9   rI   rS   )rV   r[   r.   r   )rB   rL   rI   r+   s     ` r1   rK   z_chain.from_dict+  s}    (G$ 	G%'' ;/3E{{:(G,FFFFFFFEe555)555r9   c                    t          |          dk    r*t          |d                   rt          |d                   n|} t                      j        ddd|ifi | |                    dd           | _        d| _        d | _        d S )Nr)   r   zcelery.chainrD   r+   r   r!   )	r*   r   r   rX   rY   pop	_use_linkrG   _frozenr\   r+   rS   r`   s      r1   rY   z_chain.__init__4  s    $'JJ!OOa8I8IOuQx 	gu-= 	 	 	 	 	 Z66#r9   c                 @    | j         r|                     ||          S d S r>   )r+   ri   )r\   rQ   rR   s      r1   rf   z_chain.__call__=  s,    : 	2##D&111	2 	2r9   c                    t          |t                    rKt          |          }|                                 }|s|S t	          t          ||          | j                  S t          |t                    rHt	          t          |                                 |                                          | j                  S t          |t                    r| j	        r`t          | j	        d         t                    r@| 
                                }t          |j	        d         || j                  |j	        d<   |S | j	        r[t          | j	        d         t                    r;| 
                                }|j	        d         j        |z  |j	        d         _        |S t	          t          |                                 |          | j                  S t          S )NrH   )rV   r$   r2   r   r   r   rU   r   r    r+   r   r%   bodyr   )r\   r   r+   sigs       r1   r   z_chain.__or__A  s   eU## 	"&u--E&&((E /u #'9. . . .v&& 	".""$$e&9&9&;&;= =BF)M M M My)) 	"z AjB?? Ajjll %IbM5di!9 !9 !9	"
 A
4:b>5 A A Ajjll%(Yr]%7%%?	""
 o&&((%1 16:iA A A A "!r9   c                      t            t                      j        |i |} fd|j        d         D             |j        d<   |S )Nc                 6    g | ]} |j         d           S )T)rI   r   )rU   )rn   r   r\   to_signatures     r1   r   z _chain.clone.<locals>.<listcomp>f  s<     %
 %
 %
 L$)4888%
 %
 %
r9   r+   )r'   rX   r   rR   )r\   rQ   rR   r&   r  r`   s   `   @r1   r   z_chain.clonec  si    &!EGGM42622	%
 %
 %
 %
 %
 '0%
 %
 %
	! r9   c                     d | j         D             }| j                            dg           D ]}|D ]}|                    |           |S )Nc                 6    g | ]}|                                 S rD   r   rn   ts     r1   r   z(_chain.unchain_tasks.<locals>.<listcomp>o  s     ///q///r9   r   )r+   rS   rJ   r   )r\   r+   r   r7   s       r1   r   z_chain.unchain_tasksl  sh     0/DJ///<##L"55 	% 	%C % %$$$$%r9   c           	          |r|nd}|r|ng }| j         }|j        j        r5t                      5   | j        ||fi |cd d d            S # 1 swxY w Y    | j        ||fd|i|rt          | j        fi |n| j        S )NrD   rI   )rI   conftask_always_eagerr   rt   runrW   rS   )r\   rQ   rR   rS   rI   s        r1   ri   z_chain.apply_asyncu  s   #tt!)rh8% 	;"$$ ; ;!tz$::'::; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;txf I I# I-4FD)))))$,I I 	Is   A

AAc                    |r|nd}|r|ng }|p| j         }| j        }||j        j        dk    rd}|r+| j        s$t          |          t          | j                  z   n| j        }|                     ||| j        |
|||||||          \  }}|r\|r|d         	                    d|           |
                                }t          |||          } |j        di |}|s|S |d         S d S )NrD   r)   T)r   r   r   )rI   r   r
  task_protocolrT   r[   rQ   prepare_stepsr+   r   r   r   ri   )r\   rQ   rR   r;   r%   r   r   r   	publisherr   r   r   rI   r   rS   r   r+   results_from_prepare
first_taskresult_from_applys                       r1   r  z
_chain.run  sF    #tt!)roTX> 6! ; ;H> $>deDI....48I 	 '+&8&8&$*gy*cXu+ '9 '
 '
##
   	/ :a++FD999J1'5(KKG 6
 6 A A A A  /((+A..	/ 	/r9   c                     |                      | j        | j        | j        ||d | j        |||d|          x\  }}| _        |d         S )NF)r   r   r   )r  rQ   rR   r+   rI   r   )	r\   r   r;   r%   r   r   r   re   resultss	            r1   r   z_chain.freeze  sZ     %)$6$6It{DJDHc8U%# %7 %
 %
 	

7T\
 qzr9   Tc                 \   |p| j         }| j        }||j        j        dk    rd}t	          |          }|j        }|j        }d }d }g g }}d}|r[ |            }| | }}t          |t          j	                  s |||          }t          |t                    rt          |          }|r.|r|                    ||          }n@|                                }n+|r)t          |          t          |j                  z   |_        t          |t                    r ||j                   t          |t                    rh|rf|                                 |                                 	 t#          |||j        ||          }n## t&          $ r t#          ||||          }Y nw xY w|r|                    |||	|
|          }n|                    |          }|dz  }|r'|r|                    |           |r|j        s||_        |r't/          |          D ]}|                    |           |                    |           |                    |           ||}}t          |t"                    r2|j                                         |}|j        r|j        }|j        |}|[||fS )	Nr)   Tr   rH   )r   r   r   rI   )r   r   rI   )r   r;   r%   r   r   )rI   r   r
  r  r   r   r   rV   r   CallableSignaturer$   r2   r   r[   rQ   r   r+   r%   r   r/   r   r   parentr   r   r   r   ensure_chords_allowed)r\   rQ   rR   r+   r   r   r   rI   last_task_idr;   
chord_bodyr   rK   r   r   steps	steps_popsteps_extend	prev_taskprev_resr  ir7   is_first_taskis_last_taskresr   nodes                               r1   r  z_chain.prepare_steps  sK   
 oTX > 6! ; ;He I	|	Rw  \	 9;;D /4)U<MdH$>?? 0 y3///$&& 0 *$//  ;  (::dF33DD::<<DD ;!$KK%	*:*::	$'' TZ((( $&& 9  		 9 ( 0's  DD &   
 !9 'S  DDD  3 kk #hj + "   kk'k22FA * )IIi((( *HO *&)HO -)*55 - -GOOG,,,,LLNN3"&xI$&&  11333 k ';D k 'y  \	 z g~s   +F F%$F%c           
          |r|nd}|r|ni }d ||fc}\  }}| j         D ]X} |                    ||          j        |o|                                ffi t	          | j        fi |}||dc|_        }\  }}Y|S )NrD   r   )r+   r   rt   rJ   rW   rS   r  )	r\   rQ   rR   rS   lastfargsfkwargsr7   r%  s	            r1   rt   z_chain.apply.  s    #tt!)r!%f~ugJ 	I 	ID2$**UG,,2&$((**I I*.t|*G*Gw*G*GI IC15sL.CJ.uggr9   c                 n    | j         }|$	 | j        d         j         }n# t          $ r Y nw xY w|pt          S Nr   )rU   r+   LookupErrorr   r\   rI   s     r1   rI   z
_chain.app8  sN    i;jm(   !k!    
++c                     | j         s)dt          |           j         dt          |           ddS t	          | j         d         d         d                    d | j         D                                 S )	N<@z#xz: empty>r   r7   z | c              3   4   K   | ]}t          |          V  d S r>   )reprr  s     r1   r   z"_chain.__repr__.<locals>.<genexpr>G  s(      331tAww333333r9   )r+   r]   r@   r   r   joinr   s    r1   r   z_chain.__repr__B  sx    z 	CBtDzz*BBRXXBBBBB)JqM&!JJ33
333335 5 	5r9   r>   r   )NNNNNNNNNNNNNr   )r@   r   r   r   r+   r   rK   rY   rf   r   r   r   ri   r  r   r    r  rt   r   rI   r   r   r   s   @r1   r   r   '  s}       ^->??E6 6 6 [6    2 2 2 "  "  "D      	I 	I 	I 	I @D@D=A#/ #/ #/ #/N 599=	 	 	 	 #dt#'$4 I,?"&	z z z zx    " " X"5 5 5 5 5 5 5r9   r   c                   "     e Zd ZdZ fdZ xZS )r!   a  Chain tasks together.

    Each tasks follows one another,
    by being applied as a callback of the previous task.

    Note:
        If called with only one argument, then that argument must
        be an iterable of tasks to chain: this allows us
        to use generator expressions.

    Example:
        This is effectively :math:`((2 + 2) + 4)`:

        .. code-block:: pycon

            >>> res = chain(add.s(2, 2), add.s(4))()
            >>> res.get()
            8

        Calling a chain will return the result of the last task in the chain.
        You can get to the other tasks by following the ``result.parent``'s:

        .. code-block:: pycon

            >>> res.parent.get()
            4

        Using a generator expression:

        .. code-block:: pycon

            >>> lazy_chain = chain(add.s(i) for i in range(10))
            >>> res = lazy_chain(3)

    Arguments:
        *tasks (Signature): List of task signatures to chain.
            If only one argument is passed and that argument is
            an iterable, then that'll be used as the list of signatures
            to chain instead.  This means that you can use a generator
            expression.

    Returns:
        ~celery.chain: A lazy signature that can be called to apply the first
            task in the chain.  When that task succeeds the next task in the
            chain is applied, and so on.
    c                    |sn|rlt          |          dk    st          |d                   rDt          |          dk    r|d         n|}t          t          j        |t                                S  t                      j        | g|R i |S )Nr)   r   )r*   r   r   operatoror_r!   rX   __new__)rB   r+   rR   r`   s      r1   r:  zchain.__new__{  s     	<% 	<5zzQ'%("3"3$'JJ!OOa hlE577;;;uwws5U555f555r9   )r@   r   r   r   r:  r   r   s   @r1   r!   r!   J  sC        - -`6 6 6 6 6 6 6 6 6r9   c                   Z     e Zd ZdZ edd          Zedd            Z fdZddZ	 xZ
S )	_basemapNr7   itc                 T     | |                      |d                   d|i|d         S NrR   rI   rS   )_unpack_argsrB   rL   rI   s      r1   rK   z_basemap.from_dict  s2    sC$$Qx[11KsKa	lKKKr9   c                 n     t                      j        | j        d|t          |          dfddi| d S )NrD   r7   r=  rT   T)rX   rY   
_task_namer   )r\   r7   r=  rS   r`   s       r1   rY   z_basemap.__init__  sT    ""&eBii88	 	DH	LS	 	 	 	 	r9   c           	          |r|nd}|r|ni }|                      | j                  \  }} | j        j        d|t	          |          dfdt          | j                            d                    i|S )NrD   rC  ry   r7   )r@  rR   r]   ri   r.   r8   rJ   )r\   rQ   rR   r   r7   r=  s         r1   ri   z_basemap.apply_async  s    #tt!)r$$T[11b$ty$T"XX..
 
%dkoof&=&=>>
BF
 
 	
r9   r>   r   )r@   r   r   rD  r   r@  r   rK   rY   ri   r   r   s   @r1   r<  r<    s        J:fd++LL L L [L    

 
 
 
 
 
 
 
r9   r<  c                       e Zd ZdZdZd ZdS )r"   zMap operation for tasks.

    Note:
        Tasks executed sequentially in process, this is not a
        parallel operation like :class:`group`.
    z
celery.mapc                     |                      | j                  \  }}d|j         dt          t	          |          d           dS )N[z(x) for x in d   ]r@  rR   r7   r   r4  r\   r7   r=  s      r1   r   zxmap.__repr__  sF    $$T[11bE49EE8DHHc+B+BEEEEr9   Nr@   r   r   r   rD  r   rD   r9   r1   r"   r"     s9          JF F F F Fr9   r"   c                       e Zd ZdZdZd ZdS )r#   z.Map operation for tasks, using star arguments.zcelery.starmapc                     |                      | j                  \  }}d|j         dt          t	          |          d           dS )NrH  z(*x) for x in rI  rJ  rK  rL  s      r1   r   zxstarmap.__repr__  sF    $$T[11bF49FFHT"XXs,C,CFFFFr9   NrM  rD   r9   r1   r#   r#     s3        88!JG G G G Gr9   r#   c                        e Zd ZdZ eddd          Zedd            Z fdZd Z	dd	Z
d
 Zedd            Z xZS )r   z)Partition of tasks into chunks of size n.r7   r=  nNc                 \    t          |                     |d                   d|i|d         S r?  )r   r@  rA  s      r1   rK   zchunks.from_dict  s0    s''(44N#N9NNNr9   c                 f     t                      j        dd|t          |          |dfddi| d S )Nzcelery.chunksrD   )r7   r=  rQ  rT   T)rX   rY   r   )r\   r7   r=  rQ  rS   r`   s        r1   rY   zchunks.__init__  sT    ""&eBiia@@	 	#'	+2	 	 	 	 	r9   c                      | j         di |S )NrD   rh   )r\   rS   s     r1   rf   zchunks.__call__  s    t**'***r9   c           	          |r|nd}|r|ni } |                                  j        ||fdt          | j                            d                    i|S )NrD   ry   r7   )r$   ri   r8   rR   rJ   )r\   rQ   rR   r   s       r1   ri   zchunks.apply_async  sm    #tt!)r'tzz||'&
 
%dkoof&=&=>>
BF
 
 	
r9   c                                             j                  \  }}t           fdt          t	          |          |          D              j                  S )Nc              3   F   K   | ]}t          |j                   V  dS rH   N)r#   rU   )rn   partr\   r7   s     r1   r   zchunks.group.<locals>.<genexpr>  sH       8 8 tTty999 8 8 8 8 8 8r9   rH   )r@  rR   r$   _chunksiterrU   )r\   r=  rQ  r7   s   `  @r1   r$   zchunks.group  sv    ''44b! 8 8 8 8 8")$r((A"6"68 8 8$ $ $ 	$r9   c                 0      | ||||                      S r   rD   )rB   r7   r=  rQ  rI   s        r1   apply_chunkszchunks.apply_chunks  s#    (ss4QC(((***r9   r>   r   )r@   r   r   r   r   r@  r   rK   rY   rf   ri   r$   r]  r   r   s   @r1   r   r     s        33:fdC00LO O O [O    + + +
 
 
 
$ $ $ + + + [+ + + + +r9   r   c                 V   t          | t                    rt          |           } t          | t          t          f          r| j        } n]t          | t          j                  r| g} n?t          | t                    rt          fd| D                       } nfd| D             } | S )NrH   c              3   :   K   | ]}t          |           V  dS rX  r&   rn   r  rI   s     r1   r   z_maybe_group.<locals>.<genexpr>  s0      ??A)A3///??????r9   c                 2    g | ]}t          |           S r   r`  ra  s     r1   r   z _maybe_group.<locals>.<listcomp>  s&    :::qYqc***:::r9   )
rV   rW   r&   r$   r   r+   r   r  r	   r   )r+   rI   s    `r1   _maybe_grouprc    s    % *%S)))%%)) ;	E85	6	6 ;e]++ 	;?????????EE::::E:::ELr9   c                       e Zd ZdZ edd          Zedd            Z fdZd Z	d Z
dd
Z	 	 ddZddZd Zd Zd Zej        ej        eefdZ	 	 	 d dZd Z	 	 d!dZ	 	 d!dZeZd Zd Zd Zd Zd Z e!d             Z" xZ#S )"r$   aq  Creates a group of tasks to be executed in parallel.

    A group is lazy so you must call it to take action and evaluate
    the group.

    Note:
        If only one argument is passed, and that argument is an iterable
        then that'll be used as the list of tasks instead: this
        allows us to use ``group`` with generator expressions.

    Example:
        >>> lazy_group = group([add.s(2, 2), add.s(4, 4)])
        >>> promise = lazy_group()  # <-- evaluate: returns lazy result.
        >>> promise.get()  # <-- will wait for the task to return
        [4, 8]

    Arguments:
        *tasks (List[Signature]): A list of signatures that this group will
            call. If there's only one argument, and that argument is an
            iterable, then that'll define the list of signatures instead.
        **options (Any): Execution options applied to all tasks
            in the group.

    Returns:
        ~celery.group: signature that when called will then call all of the
            tasks in the group (and return a :class:`GroupResult` instance
            that can be used to inspect the state of the group).
    r   zTasks in group.Nc                     |d         d         } t          |          fd|D                       x|d         d<   }t          |fdi|d         S )NrR   r+   c              3   :   K   | ]}t          |           V  dS rX  r   r   s     r1   r   z"group.from_dict.<locals>.<genexpr>  sI       @
 @
/3ODc***@
 @
 @
 @
 @
 @
r9   rI   rS   )r]   r$   )rB   rL   rI   
orig_tasksrebuilt_taskss     `  r1   rK   zgroup.from_dict  s     x[)
/?tJ/?/? @
 @
 @
 @
7A@
 @
 @
 0
 0
 	
(G} ]<<<q|<<<r9   c                 f   t          |          dk    rw|d         }t          |t                    r|j        }t          |t          j                  r|                                g}t          |t                    st          |          } t                      j
        ddd|ifi | d| _        d S )Nr)   r   zcelery.grouprD   r+   r$   )r*   rV   r$   r+   r   r  r   r   r   rX   rY   rG   r   s      r1   rY   zgroup.__init__  s    u::??!HE%'' $%!;<< (eV,, %egu-= 	 	 	 	 	#r9   c                      | j         |fi |S r>   rh   )r\   rc   rS   s      r1   rf   zgroup.__call__*  s    t88888r9   c                 0    t          | || j                  S )N)r   rI   )r%   rU   r   s     r1   r   zgroup.__or__-  s    T495555r9         ?c                     t          |||d          }| j        D ]%}|                    t          |                     &| S )NT)
repeatlast)	countdown)r
   r+   r   next)r\   startstopstepr=  r7   s         r1   skewz
group.skew1  sK    UD$4888J 	) 	)DHHtBxxH((((r9   Tc                    |r|nd}|t          d          |t          d          | j        }|j        j        r | j        ||fi |S | j        s|                                 S |                     |          \  }}	}
|                     | j        g |	|
|          }t                      }t           | j        ||||f||d|          }| j                            |	||          }|                                 t          |          dk    r#t          |d         t                    r|d         }|j        }|r|r|                    |           |S )NrD   z%Cannot add link to group: use a chordz5Cannot add link to group: do that on individual tasksrQ   rR   )ready_barrierr)   r   )r,   rI   r
  r  rt   r+   r   _freeze_gid	_preparedr   r.   _apply_tasksr   finalizer*   rV   current_worker_task	add_trail)r\   rQ   rR   add_to_parentr   r   r   rS   rI   r;   r   r+   pr  resultparent_tasks                   r1   ri   zgroup.apply_async7  s   #ttCDDD!GI I Ih8% 	74:dF66g666z 	!;;== %)%5%5g%>%>"7tz2x#FFII(t(#q N.26N NELN N O O%%hq%II	

 v;;!
6!9k B BAYF- 	*[ 	*!!&)))r9   c                    rndrni | j         }| j        s|                                 S |                               \  }}|                     | j        g |||          }|                    |fd|D                       S )NrD   c                 8    g | ]\  }}} |j         dd S )rv  rD   )rt   )rn   r   re   rQ   rR   rS   s      r1   r   zgroup.apply.<locals>.<listcomp>c  sE     *
 *
 *
?HsAqICI:4::'::*
 *
 *
r9   )rI   r+   r   rx  ry  r   )r\   rQ   rR   rS   rI   r;   r   r+   s    ```    r1   rt   zgroup.apply[  s    #tt!)rhz 	!;;== %)%5%5g%>%>"7tz2x#FFx *
 *
 *
 *
 *
 *
LQ*
 *
 *
   	r9   c                 D    | j         D ]}|                    |           d S r>   r+   r   r\   rT   r7   s      r1   r   zgroup.set_immutableg  s4    J 	* 	*Dy))))	* 	*r9   c                     |                                                     d          }| j        d                             |          S )NTr   r   )r   r   r+   r   r\   r   s     r1   r   z
group.linkk  s9     iikkooo--z!}!!#&&&r9   c                 D    t          fd| j        D                       S )Nc              3   B   K   | ]}|                               V  d S r>   r   )rn   
child_taskr   s     r1   r   z#group.link_error.<locals>.<genexpr>~  s1      MMJZ**3//MMMMMMr9   )r[   r+   r  s    `r1   r   zgroup.link_errorv  s*     MMMM$*MMMMMMr9   c
              #   l  K   |D ]}
 ||
|          r|
                                 }
n ||
|          }
 ||
t                    r'|
                    |
j        ||||          }|E d {V  h|r(|
j        s! |	|           |	|
j                  z   |
_        |
|
                    ||          |fV  d S )NrH   )r;   r   )r   r$   ry  r+   rT   rQ   r   )r\   r+   rc   r;   r   rI   r  rK   rV   r[   r7   unrolls               r1   ry  zgroup._prepared  s       	V 	VDz$ 122 0 zz|| !y3///z$&& 	VJh  "!!!!!!!! G G %l 3 3eeDI6F6F FDIDKK7KKKXUUUUU#	V 	Vr9   c	              +   $  K   |p| j         }|                    |          5 }d}
t          t          |                    D ]\  }\  }}|\  }}}||n|j                            d          }|
t                              |          z  }
|||j        	                    ||
            |j
        d|d|||d|	 |r5|j        s.|j        s'|xj        dz  c_        |                    |d           |V  	 d d d            d S # 1 swxY w Y   d S )	Nr   r%   F)r   r~  r%   rQ   rR   r)   T)weakrD   )rI   r   	enumerater   rS   rJ   _chord_descendr   set_chord_sizeri   	cancelledreadyr0   then)r\   r+   r   rI   r  r~  r%   rQ   rR   rS   
chord_size
task_indexcurrent_task	next_taskr   r%  r;   	chord_objs                     r1   rz  zgroup._apply_tasks  s     
 oTX$$X.. "	(
 J9B%  : :  5
5\9 &2"S(%*%6EECKOOG<T<T	 fooc222
(Y->K..xDDD +&/d6+ +")+ + +  +Q[ + +FFaKFFHHQTH***				9"	 "	 "	 "	 "	 "	 "	 "	 "	 "	 "	 "	 "	 "	 "	 "	 "	 "	s   CDD	D	c                     t          | j        fi |}|                    dt                                x|d<   }|||                    d          fS )Nr   r;   r   )rW   rS   r   r   rJ   )r\   rS   r;   s      r1   rx  zgroup._freeze_gid  sW     t|//w//KK	466**	,
h'++i"8"888r9   c           	         | j         }	 |d         }n%# t          $ r |pt                      x}|d<   Y nw xY w|r||d<   |r||d<   |||d<   |                    d|          }|                    d|          }t	          | j        t                    rt          j        | 	                    | j                            \  }	}
t          |                     |	||||                    }t          d t          |
|          D                       | _        nVg }t          |                     |||||                    }t	          | j        t                    r|| j        d d <   n|| _        ||fS )Nr   r;   r%   r   r   r   c              3   &   K   | ]}|d          V  dS )r   NrD   )rn   xs     r1   r   z,group._freeze_group_tasks.<locals>.<genexpr>  s&      BBqtBBBBBBr9   )rS   r   r   r   rV   r+   r   r   tee_unroll_tasksr   _freeze_taskszipr.   _freeze_unrollr   )r\   r   r;   r%   r   r   r   r   gidtasks1tasks2r  	new_taskss                r1   _freeze_group_taskszgroup._freeze_group_tasks  s    |	7y/CC 	7 	7 	7$,$66C$y///	7 	('D 	"!DM""-D//)W55OOK;;	dj&)) 	' ']4+=+=dj+I+IJJNFFD..vxQZ[[\\G
 BBS-A-ABBBBBDJJI 4..8UGY   G $*o66 ' )
111&
G|r   c           
      R     | j         j        |                     ||||||           S )N)r   r;   r%   r   r   r   )rI   r   r  )r\   r   r;   r%   r   r   r   s          r1   r   zgroup.freeze  s;    #tx#T%=%=hI; &> &
 &
  	r9   c              #   Z   K   fdt          |          D             E d {V  d S )Nc              3   R   K   | ]!\  }}|                     |           V  "dS )r;   r%   r   r   r   N)r   )rn   r   r7   r%   r;   r   r   s      r1   r   z&group._freeze_tasks.<locals>.<genexpr>  s^       ? ?
 *T KK&+(/*3,7	   9 9 ? ? ? ? ? ?r9   )r  )r\   r+   r;   r%   r   r   s     ````r1   r  zgroup._freeze_tasks  sv      ? ? ? ? ? ? ?
 .7u-=-=? ? ? 	? 	? 	? 	? 	? 	? 	? 	? 	?r9   c              #   4    K    fd|D             E d {V  d S )Nc              3   h   K   | ],}t          |j                                                   V  -dS rX  )r'   rU   r   rn   r7   r\   s     r1   r   z&group._unroll_tasks.<locals>.<genexpr>  s>      SSTODdi888>>@@SSSSSSr9   rD   r\   r+   s   ` r1   r  zgroup._unroll_tasks  s9      SSSSUSSSSSSSSSSSSr9   c              #     K   t          | j                  }d}|rt          |                                | j                                                  }t          |t                    r|                    |j                   n6|	                    |           |
                    |||||          V  |dz  }|d S d S )Nr   rH   r  r)   )r   r+   r'   popleftrU   r   rV   r$   
extendleftr   r   )	r\   r  r;   r%   r   r   stackr   r7   s	            r1   r  zgroup._freeze_unroll  s       dj!! 	!"5==??	BBBHHJJD$&& !  ,,,,  &&&kk8(-w,5.9 " ; ; ; ; ; q   	! 	! 	! 	! 	!r9   c                 h    | j         r*t          | j         d         d         d| j         d          S dS )Nr   r7   zgroup()zgroup(<empty>))r+   r   r   s    r1   r   zgroup.__repr__  sD    : 	*-
1f%((((* * *  r9   c                 *    t          | j                  S r>   )r*   r+   r   s    r1   __len__zgroup.__len__   s    4:r9   c                 r    | j         }|$	 | j        d         j        }n# t          $ r Y nw xY w||nt          S r,  )rU   r+   rI   r-  r   r.  s     r1   rI   z	group.app#  sQ    i;jm'   oss;6r/  r>   )rl  Nrl  )NNTNNNr   )NNNNNNNr   )$r@   r   r   r   r   r+   r   rK   rY   rf   r   rt  ri   rt   r   r   r   r   r  r    rV   r[   ry  rz  rx  r  r   r   r  r  r  r   r  r   rI   r   r   s   @r1   r$   r$     s        : ^->??E	= 	= 	= [	=$ $ $ $ $9 9 96 6 6    AE9=" " " "H
 
 
 
* * *	' 	' 	'N N N %-$>%/'uV V V V. >B/3'+( ( ( (T9 9 9 BFFJ' ' ' 'R 599=    G? ? ?T T T! ! !$        7 7 X7 7 7 7 7r9   r$   r%   c                   *    e Zd ZdZedd            Zedd            Z	 	 d fd	ZddZ	 fdZ
	 	 d d	Z	 	 	 d!d
Z	 	 d"dZed             Zd Z	 	 	 d#dZ fdZd Zd Zd Zd Zed             ZddZ edd          Z edd          Z xZS )$r  aL  Barrier synchronization primitive.

    A chord consists of a header and a body.

    The header is a group of tasks that must complete before the callback is
    called.  A chord is essentially a callback for a group of tasks.

    The body is applied with the return values of all the header
    tasks as a list.

    Example:

        The chord:

        .. code-block:: pycon

            >>> res = chord([add.s(2, 2), add.s(4, 4)])(sum_task.s())

        is effectively :math:`\Sigma ((2 + 2) + (4 + 4))`:

        .. code-block:: pycon

            >>> res.get()
            12
    Nc                 p    |                                 } | j        di |d         \  }|d<    | |d|i|S )NrR   rI   rD   )copyr@  )rB   rL   rI   rS   rQ   s        r1   rK   z_chord.from_dictJ  sP    &&(("2#"2"G"GWX5F"G"GghsD-c-W---r9   c                     | |f|fS r>   rD   )headerr   rR   s      r1   r@  z_chord._unpack_argsP  s     ~v%%r9   celery.chordc           
          |r|nd}|r|ndi i} t                      j        ||i |t          ||          t          ||          dfd|i| d| _        d S )NrD   rR   rH   )r  r   rI   r%   )rX   rY   rc  r'   rG   )	r\   r  r   r7   rQ   rR   rI   rS   r`   s	           r1   rY   z_chord.__init__V  s    #tt!5"~tBF Bl63.G.G"1$C"@"@"@B B B	 	GJ	NU	 	 	 $r9   c                 ,     | j         d|rd|ini fi |S )NrD   r   rh   )r\   r   rS   s      r1   rf   z_chord.__call__`  s,    td$BVTNNNNgNNNr9   c                     t          |t          t          f          s:t          |t                    r%|                                 }|j        |z  |_        |S t                                          |          S r>   )rV   r$   r   r    r   r   rX   r   )r\   r   r   r`   s      r1   r   z_chord.__or__c  sc    55&/22 	)eY''	) **,,Cx%'CHJ77>>%(((r9   c                    t          | j        t                    s t          | j        | j                  | _        | j                            ||| j                  }| j                            |||||          }|}	t                      }
|	rJ|	j        |
v rt          d          |
	                    |	j                   |	j
        ||	_
        n	|	j
        }	|	J| j        j        | _        |S )NrH   )r   r   r%   )r   r%   r;   r   zRecursive result parents)rV   r+   r$   rI   r   r   r   r   RuntimeErroraddr  )r\   r   r;   r%   r   r   r   header_resultbody_resultr&  seens              r1   r   z_chord.freezem  s     $*e,, 	9tztx888DJ
))	 * C C i&&# ' % % uu 	w$"#=>>>HHTW{"+;D  	 *-r9   c	                    |r|nd}|r|ni }|r+| j         s$t          |          t          | j                  z   n| j        }|                    dd           p| j        d         }
t          | j        d         fi |} |
j        di |	}
|                     |
          }t          | j	        t                    r| j	                                        nt          | j	        |          }|j        j        r8t                      5   | j        ||f|
|d|	cd d d            S # 1 swxY w Y   |	rt          | j        fi |	n| j        }|                    dd           }||} | j        ||
|fd|i|S )NrD   r   rR   rH   )r   r   r   )rT   r[   rQ   r   rR   rW   r   _get_apprV   r+   r$   r
  r  r   rt   rS   r  )r\   rQ   rR   r   r   r  r   router
result_clsrS   r   rI   r+   merged_optionsoption_task_ids                  r1   ri   z_chord.apply_async  s    #tt!)r> $>deDI....48I 	zz&$''>4;v+>dk(+66v66tz$$G$$mmD!!'1$*e'D'D 1!!###DJC000 	8% 	I"$$ I I!tz$ I'+WI I@GI II I I I I I I I I I I I I I I I ;BSdl66g666t|'++It<<?$G txtTMM7MnMMMs   D  D$'D$Tc                 J   |r|nd}|r|ni }|| j         n|}t          | j        t                    r| j                                        nt          | j        | j                  }|                    |                    ||                              |          f          S )NrD   rH   )	propagate)rQ   )r   rV   r+   r$   r   rI   rt   rJ   )r\   rQ   rR   r  r   rS   r+   s          r1   rt   z_chord.apply  s    #tt!)r Ltyyd'1$*e'D'D 6!!###DJDH555 	zz++dF++//)/DDF  
 
 	
r9   c                 ^    t          |t                    s/t          |t                    rt                              |          }t          |t                    r6t          |j        d|j                  }t           fd|D                       S t          |t                    r4|j        dd d         D ]!} 	                    |          }|dk    r|c S "dS t          |t                    r 	                    |j                  S t          |t                    rdS t          |          S )Nr+   c              3   B   K   | ]}                     |          V  d S r>   r  )rn   r7   rB   s     r1   r   z"_chord._descend.<locals>.<genexpr>  s/      ??ds||D))??????r9   r   r   r)   )rV   r    rW   rK   r$   r5   r+   sumr   r  r%   r   r*   )rB   sig_objsubtasks	child_sig
child_sizes   `    r1   r  z_chord._descend  s.    '9-- 	3*Wd2K2K 	3))'22Ggu%% 	w}gw}EEH????h??????(( 	$]26r62  	 \\)44
>>%%%% "
 q'' 	<<---++ 	17||r9   c                 p     t           j        d j                  }t           fd|D                       S )Nr+   c              3   B   K   | ]}                     |          V  d S r>   r  r  s     r1   r   z)_chord.__length_hint__.<locals>.<genexpr>  s/      9944==&&999999r9   )r5   r+   r  r  s   ` r1   r-   z_chord.__length_hint__  s;    
GTZ8899995999999r9   r)   Fc
                    |p|                      |          }|j                            d          pt                      }|j                            d          }|
rt	          | j        fi |
n| j        }
|
r0|
                    dd            |j                            |
           |                    |	|          }|
                    dd            |
                    dd            |
                    dd            |                    |||          }|j	        r*|j
                            |||||            ||d|i|
}n$|                    g             | j        j        | }||_        |S )Nr   r   r  r!   r%   )r;   r%   r   )intervalro  max_retries)r  rS   rJ   r   rW   r   r   r   r  r+   r   apply_chordrj   rI   r   r  )r\   r  r   rc   rI   r  ro  r  eagerr   rS   r;   r   bodyresheader_result_argsr  s                   r1   r  z
_chord.run  s    (T]]4((>%%i00:DFF,""9--3:L$t|//w/// 	)KK	4(((L(((++gw+77 	GT"""GT"""It$$$#77QU_f7gg< 	FK##"!#' $    #FLN(NgNNMM
 JJrNNN0DH02DEM&r9   c                      t                      j        |i |}	 t          |j        d         d          |j        d<   n# t          t
          f$ r Y nw xY w|S )Nr   Tr  )rX   r   r'   rR   r/   r   )r\   rQ   rR   r&   r`   s       r1   r   z_chord.clone  sy    !EGGM42622		'6 ((6 (6 (6IV$$) 	 	 	D	s   $A AAc                 :    | j                             |           |S r>   )r   r   r   s     r1   r   z_chord.link  s    	x   r9   c                 :    | j                             |           |S r>   )r   r   r   s     r1   r   z_chord.link_error  s    	W%%%r9   c                 D    | j         D ]}|                    |           d S r>   r  r  s      r1   r   z_chord.set_immutable	  s4    J 	* 	*Dy))))	* 	*r9   c                    | j         rt          | j         t                    rt          | j         j        d         d         d                    | j         j        d                             | j                  t          | j         j        dd          | j                                      S dt          | j         d         | j                             | j                            z   S d| j        dS )	Nr   r7   z%({} | {!r})r)   rH   %z<chord without body: >)	r   rV   r   r   r+   formatr   r!   rU   r   s    r1   r   z_chord.__repr__  s    9 
	C$)V,, 1IOA&v."))	*33DJ??dioabb1tyAAA    3	&!49#5#5dj#A#AC C C C6tz6666r9   c                 6    |                      | j                  S r>   )r  r   r   s    r1   rI   z
_chord.app  s    }}TY'''r9   c                     | j         }|?	 | j        j        }n# t          $ r
 | j        }Y nw xY w|r|d         j         }|	||j         }||nt          S r,  )rU   r+   r/   r   )r\   r   rI   r+   s       r1   r  z_chord._get_app   sw    i;#
(! # # #
# $Ahm{t/ioss;6s    ,,zkwargs.headerzTasks in chord header.zkwargs.bodyzBody task of chord.r>   r   )Nr  NNNr   )NNNNNNNN)NNTN)NNr)   NFN)r@   r   r   r   r   rK   staticmethodr@  rY   rf   r   r   ri   rt   r  r-   r  r   r   r   r   r   r   rI   r  r   r+   r   r   r   s   @r1   r  r  .  s        4 . . . [.
 & & & \&
 0>-1$ $ $ $ $ $O O O O) ) ) ) ) 599=   : ;?>B,0N N N N4 '+#'	
 	
 	
 	
   [6: : : BF16& & & &P        * * *
7 7 7 ( ( _(7 7 7 7 _.FGGEM+@AADDDDDr9   r  c                 
   |                     d          }t          | t                    rJt          | t          j                  r|                                 S t                              | |          S t          | g|R i |S )zCreate new signature.

    - if the first argument is a signature already then it's cloned.
    - if the first argument is a dict, then a Signature version is returned.

    Returns:
        Signature: The resulting signature.
    rI   rH   )rJ   rV   rW   r   r  r   r    rK   )variesrQ   rR   rI   s       r1   r&   r&   6  s     **U

C&$ 4fh899 	"<<>>!""6s"333V-d---f---r9   Fc                     | ^t          | t          j                  r|r|                                 } n$t          | t                    rt          |           } ||| _        | S )a  Ensure obj is a signature, or None.

    Arguments:
        d (Optional[Union[abstract.CallableSignature, Mapping]]):
            Signature or dict-serialized signature.
        app (celery.Celery):
            App to bind signature to.
        clone (bool):
            If d' is already a signature, the signature
           will be cloned when this flag is enabled.

    Returns:
        Optional[abstract.CallableSignature]
    )rV   r   r  r   rW   r&   rU   )rL   rI   r   s      r1   r'   r'   J  sb     	}a344 	 GGII4   	!A?AFHr9   )NF)Gr   r   r8  collectionsr   collections.abcr   r  r   	functoolsr   r   r   r   typesr	   kombu.utils.functionalr
   r   kombu.utils.objectsr   kombu.utils.uuidr   viner   celery._stater   celery.resultr   r   celery.utilsr   celery.utils.collectionsr   celery.utils.functionalr   r   rZ  r   r   r   r   r   r   celery.utils.objectsr   celery.utils.textr   r   __all__r2   r8   r  registerrW   r    r   rE   r   r!   r<  r"   r#   rc  r$   r  r%   r&   subtaskr'   maybe_subtaskrD   r9   r1   <module>r     s               + + + + + +       ) ) ) ) ) )                   4 4 4 4 4 4 4 4 / / / / / / ! ! ! ! ! !       % % % % % % 8 8 8 8 8 8 8 8 ! ! ! ! ! ! - - - - - - * * * * * * 5 5 5 5 5 5F F F F F F F F F F F F F F F F 1 1 1 1 1 1 B B B B B B B B6 6 6 ' ' ' 
$nD nD nD nD nD nD nD %$nDb6! 6! 6!r g&&_5 _5 _5 _5 _5Y _5 _5 '&_5D	96 96 96 96 96F 96 96 96x
 
 
 
 
y 
 
 
0 F F F F F8 F F F G G G G Gx G G G #+ #+ #+ #+ #+Y #+ #+ #+L    z7 z7 z7 z7 z7I z7 z7 z7z	 g&&B B B B BY B B '&BH 	. . ."    6  r9   