HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/celery/__pycache__/bootsteps.cpython-310.pyc
o

-we�/�@s&dZddlmZddlmZddlmZddlmZddl	m
Z
ddlmZm
Z
dd	lmZmZdd
lmZzddlmZWneyIdZYnwefZd
ZdZdZdZee�Zdd�Zdd�ZGdd�de
�ZGdd�d�Z Gdd�de!�Z"Gdd�de"d�Z#Gdd�de#�Z$Gdd �d e$�Z%d!S)"z0A directed acyclic graph of reusable components.�)�deque)�Event)�
ignore_errors)�bytes_to_str��symbol_by_name�)�DependencyGraph�GraphFormatter)�instantiate�qualname)�
get_logger)�GreenletExit�)�	Blueprint�Step�
StartStopStep�ConsumerStep��cCsd|j�d|��S)Nz| z: ��alias)�ns�fmtrr�I/home/arjun/projects/env/lib/python3.10/site-packages/celery/bootsteps.py�_pre�rcCs|j�dd�dS)N�.r���)�name�rsplit)�srrr�_label#rr"c@sDeZdZdZdZdZdddd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�
StepFormatterz'Graph formatter for :class:`Blueprint`.u⧉u∘�
parallelogram�
slategray4�
slategray3)�shape�color�	fillcolorcCs,|od�|�|�t|jpt|��dd���S)Nz{}{}zutf-8�ignore)�format�_get_prefixr�labelr"�encode��self�steprrrr-2s��zStepFormatter.labelcCs|jr|jS|jr|jSdS)N�)�last�blueprint_prefix�conditional�conditional_prefixr/rrrr,9s
zStepFormatter._get_prefixcKs |jr|jn|j}|�|||�S�N)r3�blueprint_scheme�node_scheme�	draw_node)r0�obj�attrs�schemerrr�node@szStepFormatter.nodecKs&|jr
|jddd�|�|||j|�S)N�none�
darkseagreen3)�	arrowheadr()r3�update�	draw_edge�edge_scheme)r0�a�br<rrr�edgeDszStepFormatter.edgeN)�__name__�
__module__�__qualname__�__doc__r4r6r8r-r,r>rGrrrrr#'s�r#c@s�eZdZdZeZdZdZdZe	�Z
ddedede
diZ		d3dd	�Zd
d�Zdd
�Zdd�Zdd�Z		d4dd�Z	d5dd�Zd6dd�Zd7dd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Z e!d1d2��Z"dS)8ra�Blueprint containing bootsteps that can be applied to objects.

    Arguments:
        steps Sequence[Union[str, Step]]: List of steps.
        name (str): Set explicit name for this blueprint.
        on_start (Callable): Optional callback applied after blueprint start.
        on_close (Callable): Optional callback applied before blueprint close.
        on_stopped (Callable): Optional callback applied after
            blueprint stopped.
    Nr�initializing�running�closing�terminatingcCsT|p
|jp
tt|��|_t|pg�t|j�B|_||_||_||_t	�|_
i|_dSr7)rr�type�set�
default_steps�types�on_start�on_close�
on_stoppedr�shutdown_complete�steps)r0rXrrTrUrVrrr�__init__cs
zBlueprint.__init__cCsbt|_|jr
|��tdd�|jD��D]\}}|�d|j�|d|_|�|�t	�
d�qdS)Ncss�|]	}|dur|VqdSr7r��.0r!rrr�	<genexpr>qs�z"Blueprint.start.<locals>.<genexpr>zStarting %srz^-- substep ok)�RUN�staterT�	enumeraterX�_debugr�started�start�logger�debug)r0�parent�ir1rrrrbms

�zBlueprint.startcCs|j|jpdS�Nr)�
state_to_namer^�r0rrr�human_statew�zBlueprint.human_statecCs(i}|jD]}|�|�|�pi�q|Sr7)rXrB�info)r0rerlr1rrrrlzs
zBlueprint.infocCs$|jr|��|j|dddd�dS)N�closerNF)�reverse)rU�send_all�r0rerrrrm�szBlueprint.close�stop�
restartingFcCs|j||||d�dS)N)�	propagate)ro)r0re�method�descriptionrsrrr�restart�szBlueprint.restartTrcCs�|p|�dd�}|rt|j�n|j}|D]A}|rUt||d�}	|	durU|�d|��|j�z
|	|g|�R�WqtyT}
z|rA�t�	d||j|
�WYd}
~
qd}
~
wwqdS)N�_� z%s %s...zError on %s %s: %r)
�replace�reversedrX�getattrr`�
capitalizer�	Exceptionrc�	exception)r0rertrurnrs�argsrXr1�fun�excrrrro�s*
�
�����zBlueprint.send_allcCs�|rdnd}|jttfvrdS|jtks|jt|j�kr&t|_|j��dS|�	|�t|_|j
||r5dnd|dd�|jrB|��t|_|j��dS)NrO�stopping�	terminaterqF)rurs)r^�CLOSE�	TERMINATEr]ra�lenrXrWrQrmrvrV)r0rermr��whatrrrrq�s"

�zBlueprint.stopcCs*z
|jj|d�WdStyYdSw)N)�timeout)rW�wait�
IGNORE_ERRORS)r0r�rrr�join�s
�zBlueprint.joincKs�|�d�g}|_|��}|_|�d�|�|�D]}||fi|��}|||j<|�|�q|�dd�dd�|jD���|D]}|�|�qA|S)arApply the steps in this blueprint to an object.

        This will apply the ``__init__`` and ``include`` methods
        of each step, with the object as argument::

            step = Step(obj)
            ...
            step.include(obj)

        For :class:`StartStopStep` the services created
        will also be added to the objects ``steps`` attribute.
        zPreparing bootsteps.zBuilding graph...zNew boot order: {%s}z, cs��|]}|jVqdSr7rrZrrrr\���z"Blueprint.apply.<locals>.<genexpr>)	r`�order�claim_stepsrX�_finalize_stepsr�appendr��include)r0re�kwargsr�rX�Sr1rrr�apply�s



�zBlueprint.applycCs8|jj�|jj�|j�t|jd�t|jd��dS)Nrr)�graph�adjacentrB�add_edgerPr�)r0�otherrrr�connect_with�s&zBlueprint.connect_withcCs
|j|Sr7)rX)r0rrrr�__getitem__��
zBlueprint.__getitem__cCstdd�|j��D�d�S)Ncss�|]}|jr|VqdSr7)r3�r[�Crrrr\���z'Blueprint._find_last.<locals>.<genexpr>)�nextrX�valuesrirrr�
_find_last�szBlueprint._find_lastcCs~|��D]}dd�|jD�|_qtdd�|��D��}|r=|��D]}t|�}|j|jvr2|||j<|�|j�q!|sdSdS)NcSsg|]}t|��qSrr)r[�deprrr�
<listcomp>�sz(Blueprint._firstpass.<locals>.<listcomp>csr�r7��requires�r[r1rrrr\�r�z'Blueprint._firstpass.<locals>.<genexpr>)r�r�r�popleftrrrXr�)r0rXr1�streamr>rrr�
_firstpass�s
�zBlueprint._firstpassc
Cs�|��}|�|�dd�|��D�}t||j|d�d�}|_|r0|D]}||kr/|�||�q#z|��WStyG}ztd|��d}~ww)Ncss�|]}||jfVqdSr7r�r�rrrr\�r�z,Blueprint._finalize_steps.<locals>.<genexpr>)�root)�	formatterzunknown bootstep: %s)	r�r�r�r	r
r�r��topsort�KeyError)r0rXr3�it�Gr;r�rrrr��s"
��
��zBlueprint._finalize_stepscst�fdd��jD��S)Nc3s�|]}��|�VqdSr7)�	load_stepr�rirrr\�r�z(Blueprint.claim_steps.<locals>.<genexpr>)�dictrSrirrirr���zBlueprint.claim_stepscCst|�}|j|fSr7)rrr/rrrr��s
zBlueprint.load_stepcGstjt||�g|�R�Sr7)rcrdr)r0�msgrrrrr`r�zBlueprint._debugcCst|�Sr7)r"rirrrrszBlueprint.alias)NNNNN)rqrrF)NTTr)TFr7)#rHrIrJrKr#r
rr^rarQrRr]r�r�rhrYrbrjrlrmrvrorqr�r�r�r�r�r�r�r�r�r`�propertyrrrrrrJsJ�
�


�
�

rcs8eZdZdZdZdZ�fdd�Zdd�Zdd�Z�Z	S)	�StepTypezMeta-class for steps.NcsJ|�d�}|r|�d|��n|}|j||�d�p|d�t��||||�S)NrIrr)rJr)�getrB�super�__new__)�clsr�basesr<�module�qname��	__class__rrr�s
�zStepType.__new__cC�|jSr7)r�r�rrr�__str__szStepType.__str__cCs
d�|�S)Nzstep:{0.name}{{{0.requires!r}}})r+r�rrr�__repr__r�zStepType.__repr__)
rHrIrJrKrr�r�r�r��
__classcell__rrr�rr�
s	r�c@steZdZdZdZdZdZdZdZdZ	dd�Z
dd	�Zd
d�Zdd
�Z
dd�Zdd�Zdd�Zedd��Zdd�ZdS)rz�A Bootstep.

    The :meth:`__init__` method is called when the step
    is bound to a parent object, and can as such be used
    to initialize attributes in the parent object at
    parent instantiation-time.
    NFrTcK�dSr7r)r0rer�rrrrY?�z
Step.__init__cCr�)z�Return true if bootstep should be included.

        You can define this as an optional predicate that decides whether
        this step should be created.
        )�enabledrprrr�
include_ifBszStep.include_ifcOst|g|�Ri|��Sr7)r)r0rrr�rrrrJszStep.instantiatecCs|�|�rd|�|�fSdS)NT)FN)r��createrprrr�_should_includeMs
zStep._should_includecCs|�|�dSrg)r�rprrrr�R�zStep.includecCsdS)zCreate the step.Nrrprrrr�UszStep.createcCsd|j�d�S)Nz<step: �>rrirrrr�Xr�z
Step.__repr__cCs|jpt|�Sr7)r-r"rirrrr[sz
Step.aliascCr�r7r)r0r;rrrrl_r�z	Step.info)rHrIrJrKrr-r5r�r3r�rYr�rr�r�r�r�r�rrlrrrrr s$	
r)�	metaclassc@s<eZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	dS)
rz3Bootstep that must be started and stopped in order.NcC�|jr|j��SdSr7)r;rbrprrrrbk�
�zStartStopStep.startcCr�r7)r;rqrprrrrqor�zStartStopStep.stopcCr�r7rrprrrrmsr�zStartStopStep.closecCs|jr
t|jd|jj��SdS)Nr�)r;r{rqrprrrr�vs�zStartStopStep.terminatecCs(|�|�\}}|r||_|j�|�|Sr7)r�r;rXr�)r0re�inc�retrrrr�zs
zStartStopStep.include)
rHrIrJrKr;rbrqrmr�r�rrrrrcsrc@sBeZdZdZdZdZdd�Zdd�Zdd	�Zd
d�Z	dd
d�Z
dS)rz(Bootstep that starts a message consumer.)z!celery.worker.consumer:ConnectionNcCstd��)Nzmissing get_consumers)�NotImplementedError)r0�channelrrr�
get_consumers�szConsumerStep.get_consumerscCs2|j��}|�|�|_|jpgD]}|��qdSr7)�
connectionr�r��	consumers�consume)r0�cr��consumerrrrrb�s


�zConsumerStep.startcC�|�|d�dS)NT��_close�r0r�rrrrq�rkzConsumerStep.stopcCr�)NFr�r�rrr�shutdown�rkzConsumerStep.shutdownTcCsVt�}|jpgD]}|rt|j|j�|jr|�|j�q|D]	}t|j|j�qdSr7)rQr�rr��cancelr��addrm)r0r��cancel_consumers�channelsr�r�rrrr��s��zConsumerStep._close)T)rHrIrJrKr�r�r�rbrqr�r�rrrrr�srN)&rK�collectionsr�	threadingr�kombu.commonr�kombu.utils.encodingr�kombu.utils.importsr�utils.graphr	r
�
utils.importsrr�	utils.logr
�greenletr�ImportErrorr��__all__r]r�r�rHrcrr"r#rrPr�rrrrrrr�<module>s:�#AC