
    `f	                         d Z ddlmZ ddlmZ ddlmZ dZ ee          Z	e	j
        e	j        e	j        cZ
ZZ G d dej                  Zd	S )
z-Worker <-> Worker Sync at startup (Bootstep).    )	bootsteps)
get_logger   )Events)Minglec                   h     e Zd ZdZd ZefZddhZd fd	Zd Z	d Z
d Zd	 Zd
 ZddZd Zd Z xZS )r   zBootstep syncing state with neighbor workers.

    At startup, or upon consumer restart, this will:

    - Sync logical clocks.
    - Sync revoked tasks.

    amqpredisFc                     | o|                      |j                  | _         t                      j        |fd|i| d S )Nwithout_mingle)compatible_transportappenabledsuper__init__)selfcr   kwargs	__class__s       O/var/www/html/env/lib/python3.11/site-packages/celery/worker/consumer/mingle.pyr   zMingle.__init__   s_    ))Nd.G.G.N.N	8 	8,	806	8 	8 	8 	8 	8    c                     |                                 5 }|j        j        | j        v cd d d            S # 1 swxY w Y   d S N)connection_for_read	transportdriver_typecompatible_transports)r   r   conns      r   r   zMingle.compatible_transport    s    $$&& 	L$>-1KK	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	Ls   599c                 0    |                      |           d S r   )sync)r   r   s     r   startzMingle.start$   s    		!r   c                 J    t          d                                          }|rkt          dt          d |                                D                                   fd|                                D              t          d           d S t          d           d S )Nzmingle: searching for neighborszmingle: sync with %s nodesc                     g | ]	\  }}||
S  r$   ).0replyvalues      r   
<listcomp>zMingle.sync.<locals>.<listcomp>,   s!    IIIu5IeIIIr   c                 H    g | ]\  }}|                     ||          S r$   )on_node_reply)r%   nodenamer&   r   r   s      r   r(   zMingle.sync.<locals>.<listcomp>-   sC     > > > 5u>T8U33 > > >r   zmingle: sync completezmingle: all alone)info
send_hellolenitems)r   r   repliess   `` r   r    zMingle.sync'   s    ./////!$$ 	&-IIIIIJJL L L> > > > >$+MMOO> > > >()))))$%%%%%r   c                     |j         j                            d|j                  }|j        j        j        }|                    |j        |j	                  pi }|
                    |j        d            |S )Ng      ?)timeout
connection)r   controlinspectr3   
controllerstaterevokedhellohostname_datapop)r   r   r5   our_revokedr0   s        r   r-   zMingle.send_hello3   se    %-'''MMl(0--
K,=>>D"AJ%%%r   c                     t          d|           	  | j        |fi | d S # t          $ r  t          $ r}t	          d||           Y d }~d S d }~ww xY w)Nz mingle: processing reply from %szmingle: sync with %s failed: %r)debugsync_with_nodeMemoryError	Exception	exception)r   r   r+   r&   excs        r   r*   zMingle.on_node_reply:   s    0(;;;	HD++U+++++ 	 	 	 	H 	H 	H73GGGGGGGGG	Hs   " AAANc                 ^    |                      ||           |                     ||           d S r   )on_clock_eventon_revoked_received)r   r   clockr8   r   s        r   r@   zMingle.sync_with_nodeC   s4    Au%%%  G,,,,,r   c                     |r!|j         j                            |           d S |j         j                                         d S r   )r   rH   adjustforward)r   r   rH   s      r   rF   zMingle.on_clock_eventG   s@    %*E5!!!!!0C0C0E0E0E0E0Er   c                 V    |r&|j         j        j                            |           d S d S r   )r6   r7   r8   update)r   r   r8   s      r   rG   zMingle.on_revoked_receivedJ   s6     	7L&--g66666	7 	7r   )F)NN)__name__
__module____qualname____doc__labelr   requiresr   r   r   r!   r    r-   r*   r@   rF   rG   __classcell__)r   s   @r   r   r      s          EyH#W-8 8 8 8 8 8
L L L  
& 
& 
&  H H H- - - -F F F7 7 7 7 7 7 7r   r   N)rQ   celeryr   celery.utils.logr   eventsr   __all__rN   loggerr?   r,   rC   StartStopStepr   r$   r   r   <module>r[      s    3 3       ' ' ' ' ' '      
	H		v{F4D tY?7 ?7 ?7 ?7 ?7Y$ ?7 ?7 ?7 ?7 ?7r   