
    `fV2                         d Z ddl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
mZ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 ddlmZmZmZ  ee          Z G d de          Z  G d dej!                  Z" G d de          Z# G d de          Z$ e             Z% e"            Z& e#            Z' e$            Z(ej)        *                    d          Z+	 	 	 dldZ, ej-        eddi           ej.        dd e ed                    ee'dd           ej.        dd edddd!"           ej.        d#d$e ej/                    d% dd&'           ej.        d(d)d*eedd+           ej.        d,d-d.e ej!        d/          dd0           ej.        d1e0d2d3 edd45           ej.        d6d7e0d8d9 ed:d;5           ej.        d<d=d>e&ed:d?@           ej.        dAdBdCdded:dDE           ej.        dFe1ed:dGH           ej.        dIe1ed:dJH           ej.        dKe0ed:dLH           ej.        dMe0ed:dNH           ej.        dOdPdedQR           ej.        dSdTe
edQU           ej.        dVdWe
edQU           ej.        dXdYe
edQU           ej.        dZded[R           ej.        d\ded[R           ej.        d]ded[R           ej.        d^e0ed[U           ej.        d_e(ed[U           ej.        d`dae%eddbc           ej.        dddedfdg edbh           ej.        diedbj          ej2        e	 	 dmdk                                                                                                                                                                                                                                                                                                                                                Z3dS )nz/Program used to start a Celery worker instance.    N)	ParamType)StringParamType)concurrency)COMMA_SEPARATED_LIST	LOG_LEVELCeleryDaemonCommandCeleryOptionhandle_preload_options)BasePool)SecurityError)
EX_FAILUREEX_OKdetachedmaybe_drop_privileges)
get_logger)default_nodenamehost_formatnode_formatc                       e Zd ZdZdZd ZdS )
CeleryBeatzCelery Beat flag.beatc                 V    |j         j        j        r|r|                     d           |S )NzR-B option does not work on Windows.  Please run celery beat as a separate service.)objapp
IS_WINDOWSfailselfvalueparamctxs       C/var/www/html/env/lib/python3.11/site-packages/celery/bin/worker.pyconvertzCeleryBeat.convert   s@    7;! 	Ge 	GII F G G G     N__name__
__module____qualname____doc__namer#    r$   r"   r   r      s.        D    r$   r   c                   0     e Zd ZdZdZ fdZ fdZ xZS )WorkersPoolzWorkers pool option.poolc                 l    t                                          t          j                               dS )z=Initialize the workers pool option with the relevant choices.N)super__init__r   get_available_pool_names)r   	__class__s    r"   r1   zWorkersPool.__init__(   s*    =??@@@@@r$   c                 `   t          |t                    rt          |t                    r|S t	                                          |||          }|j        j        j        j	        }|dk    r|rt          j        |          }n*t          j        |          }|st          j        |          }|S )Nprefork)
isinstancetype
issubclassr   r0   r#   r   r   confworker_poolr   get_implementation)r   r   r    r!   r:   r3   s        r"   r#   zWorkersPool.convert,   s     eT"" 	z%'B'B 	Luc22gk&2I+  2;??EE2599E D#6{CCr$   )r&   r'   r(   r)   r*   r1   r#   __classcell__)r3   s   @r"   r-   r-   #   sa        DA A A A A        r$   r-   c                       e Zd ZdZdZd ZdS )HostnamezHostname option.hostnamec                 :    t          t          |                    S N)r   r   r   s       r"   r#   zHostname.convertG   s    +E22333r$   Nr%   r+   r$   r"   r>   r>   B   s.        D4 4 4 4 4r$   r>   c                       e Zd ZdZdZd ZdS )	AutoscalezAutoscaling parameter.z<min workers>, <max workers>c           
      <   |                     d          }t          |          dk    r&|                     dt          |           d           t          |          dk    rB	 t          |d                   df}n)# t          $ r |                     d| d           Y nw xY w	 t          t          t          t          t          |                                        S # t          $ r0 |                     d|	                    d           d           Y d S w xY w)	N,   z9Expected two comma separated integers or one integer.Got z	 instead.   r   zExpected an integer. Got z*Expected two comma separated integers.Got )
splitlenr   int
ValueErrortuplereversedsortedmapjoinr   s       r"   r#   zAutoscale.convertP   sQ   C  u::>>II 3 ZZ3 3 3 4 4 4 u::??HU1X* H H H		FeFFFGGGGGH	9&S%"9"9::;;; 	9 	9 	9II 8"ZZ__8 8 8 9 9 9 9 9 9	9s$   #A; ;#B! B!%;C! !6DDNr%   r+   r$   r"   rC   rC   K   s.          )D9 9 9 9 9r$   rC   
C_FAKEFORKFc           
         t           rdn|}t          ||          }t          |||||||d          5  	 |
|
} t          j        | | g|z              t
          cddd           S # t          $ rq |	ddlm} |}	|	j	        
                    d||           t                              d	d
                    | g|z             d           t          cY cddd           S w xY w# 1 swxY w Y   dS )zDetach program by argv.rG   F)after_forkersNr   )current_appERROR)r?   zCan't exec %r T)exc_info)rQ   r   r   osexecvr   	ExceptionceleryrT   logsetup_logging_subsystemloggercriticalrP   r   )pathargvlogfilepidfileuidgidumaskworkdirfaker   
executabler?   rT   s                r"   detachrj   l   s    $11D
 '8,,G	'7CeWd %
' 
' 
'  	%!HTD6D=)))         	 	 	{......!G++8 , 5 5 5OOOSXXtftm-D-D%)  + + +       	         s/   C##A%%A,C C#C  C##C'*C'allow_extra_argsT)clscontext_settingsz-nz
--hostnamezWorker Optionsz]Set custom hostname (e.g., 'w1@%%h').  Expands: %%h (hostname), %%n (name) and %%d, (domain).)defaultrl   r7   
help_grouphelp-D--detachz%Start worker as a background process.)rl   is_flagrn   ro   rp   z-Sz	--statedbc                 2    |p| j         j        j        j        S rA   )r   r   r9   worker_state_dbr!   _r   s      r"   <lambda>rx      s    >cgk.> r$   zPPath to the state database. The extension '.db' may be appended to the filename.)rl   r7   callbackro   rp   z-lz
--loglevelWARNINGzLogging level.z-Oz--optimizationrn   )rn   fairzApply optimization profile.z--prefetch-multiplierz<prefetch multiplier>c                 2    |p| j         j        j        j        S rA   )r   r   r9   worker_prefetch_multiplierrv   s      r"   rx   rx      s    Icgk.I r$   z>Set custom prefetch multiplier value for this worker instance.)r7   metavarry   rl   ro   rp   z-cz--concurrencyz<concurrency>c                 2    |p| j         j        j        j        S rA   )r   r   r9   worker_concurrencyrv   s      r"   rx   rx      s    Acgk.A r$   zPool OptionszlNumber of child processes processing the queue.  The default is the number of CPUs available on your system.z-Pz--poolr5   zPool implementation.)rn   r7   rl   ro   rp   z-Ez--task-eventsz--eventszdSend task-related events that can be captured by monitors like celery events, celerymon, and others.)rs   rn   rl   ro   rp   z--time-limitz;Enables a hard time limit (in seconds int/float) for tasks.)r7   rl   ro   rp   z--soft-time-limitz;Enables a soft time limit (in seconds int/float) for tasks.z--max-tasks-per-childzfMaximum number of tasks a pool worker can execute before it's terminated and replaced by a new worker.z--max-memory-per-childa  Maximum amount of resident memory, in KiB, that may be consumed by a child process before it will be replaced by a new one.  If a single task causes a child process to exceed this limit, the task will be completed and the child process will be replaced afterwards.
Default: no limit.z--purgez	--discardzQueue Options)rs   rl   ro   z--queuesz-Q)r7   rl   ro   z--exclude-queuesz-Xz	--includez-Iz--without-gossipFeaturesz--without-minglez--without-heartbeatz--heartbeat-intervalz--autoscalez-Bz--beatzEmbedded Beat Options)r7   rl   rs   ro   z-sz--schedule-filenamez
--schedulec                 2    |p| j         j        j        j        S rA   )r   r   r9   beat_schedule_filenamerv   s      r"   rx   rx   !  s    Ecgk.E r$   )ry   rl   ro   z--scheduler)rl   ro   c
                 b   	 | j         j        }| j        rP	 |                    | j        d           n2# t          t
          f$ r}t          j        d| |           d}~ww xY w|
                    dd          rdd	gt          j
        d
d         z   }d|v r|                    d           d|v r|                    d           d|v r|                    d           d|v r|                    d           t          t          j        ||||||
                    dd          |
                    dd          ||
                    dd          |          S t          ||            |j        d||||t!          ||          t!          |	|          | j         j        | j         j        d|
}|                                 |                     |j                   dS # t,          $ rE}| j                             |j        d                    |                     d
           Y d}~dS d}~ww xY w)a*  Start worker instance.

    
    Examples
    --------

    
    $ celery --app=proj worker -l INFO
    $ celery -A proj worker -l INFO -Q hipri,lopri
    $ celery -A proj worker --concurrency=4
    $ celery -A proj worker --concurrency=1000 -P eventlet
    $ celery worker --autoscale=10,0

    worker)	namespacez?Unable to parse extra configuration from command line.
Reason: )r!   Nrj   Fz-mr[   rG   rr   rq   z--uidz--gidrf   rg   ri   )	rb   rc   rd   re   rf   rg   r   ri   r?   )rd   re   )r?   pool_clsloglevelrb   rc   statedbno_colorquietr   r+   )r   r   argsconfig_from_cmdlineKeyErrorrK   click
UsageErrorgetsysra   removerj   ri   r   Workerr   r   r   startexitexitcoder   error)r!   r?   r   r   rd   re   r   rb   rc   r   kwargsera   r   s                 r"   r   r      s~   f-gk8 	--''H'EEEEj) - - -&# # #(+- - - --
 ::h&& 	-(#chqrrl2DT!!J'''t||D!!!$G$$$$G$$$#.")")!s &

7D 9 9"(**Y"="=!%+ZZd%C%C#+	- 	- 	- 	- 	#3//// 82222W%'-    	!!!!!   afQi   s?   G 3 G A"AA""C5G BG 
H.):H))H.)
NNNNNNFNNN)	NNNNNNNNN)4r)   rX   r   r   r   click.typesr   r[   r   celery.bin.baser   r   r   r	   r
   celery.concurrency.baser   celery.exceptionsr   celery.platformsr   r   r   r   celery.utils.logr   celery.utils.nodenamesr   r   r   r&   r^   r   Choicer-   r>   rC   CELERY_BEATWORKERS_POOLHOSTNAME	AUTOSCALEenvironr   rQ   rj   commandoptionPathrJ   floatpass_contextr   r+   r$   r"   <module>r      s   5 5 				 



        ' ' ' ' ' '      5 5 5 5 5 5 5 5 5 5 5 5 5 5 , , , , , , + + + + + + O O O O O O O O O O O O ' ' ' ' ' ' M M M M M M M M M M	H		
 
 
 
 
 
 
 
    %,   >4 4 4 4 4 4 4 49 9 9 9 9	 9 9 92 jll{}}8::IKK	Z^^L))
 8<?C%)   8 &!3T :< < <d!k"2"24"8"899)LM M M d):< < < d5:<<? ?)/0 0 0 d)#% % % d5< 344)02 2 2 %-J J)/0 0 0 d%B B'&
' 
' 
' d')+ + + d'AB B B n'7	8 8 8 !'7	8 8 8 %'C	D D D &'(		) 	) 	) i(	* * *
 j'(	* * *
  '(	* * *
 k'(	* * *
  #% % %  #% % % ##' ' ' $#' ' ' m#' ' ' d02 2 2 d#F F02 2 2 m02 2 2 FJ>B> > >  2 22 22 2	' '	' '	' '	% %	% %* ** ** ** *	) 	)D D8 88 8B B+ +
' 
'0 02 2% %0 0< <M M< <D> > >r$   