HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //usr/local/lib/python3.9/site-packages/celery/apps/__pycache__/worker.cpython-39.pyc
a

X>hIO�@sBdZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZddl
mZddlmZmZmZdd	lmZdd
lmZddlmZmZmZmZddlmZmZdd
lm Z ddl!m"Z"ddl#m$Z$m%Z%m&Z&ddl'm(Z(ddl)m*Z*dZ+e$e,�Z-ej�.d�Z/e0ed�Z1gd�Z2dZ3dZ4dd�Z5ej6fdd�Z7Gdd�de*�Z8ddded fe8d!�d"d#�Z9e8d!�d$d%�Z:e8d!�d&d'�Z;e8d!�d(d)�Z<e
d*k�r�ee9dd+e<ed,�Z=nee9ddd-�Z=e/�s�ee9d*d+e<ed,�Z>nd.d/�Z=Z>d0d1�Z?e/�see9d2e?ed3�Z@nd4d5�Z@d6d7�ZAdDd9d:�ZBdEd<d=�ZCdFd@dA�ZDdGdBdC�ZEdS)Hz�Worker command-line program.

This module is the 'program-version' of :mod:`celery.worker`.

It does everything necessary to run that module
as an actual application, like installing signal handlers,
platform tweaks, and so on.
�N)�datetime)�partial)�
REMAP_SIGTERM)�current_process)�safe_str)�VERSION_BANNER�	platforms�signals)�trace)�	AppLoader)�
EX_FAILURE�EX_OK�check_privileges�isatty)�static�term)�cry)�qualname)�
get_logger�
in_sighandler�set_in_sighandler)�	pluralize)�WorkController)�Worker�java�pypy_version_info)� --------------�--- ***** -----�-- ******* ----�- *** --- * ---�- ** ----------r r r rrrrz�{hostname} v{version}

{platform} {timestamp}

[config]
.> app:         {app}
.> transport:   {conninfo}
.> results:     {results}
.> concurrency: {concurrency}
.> task events: {events}

[queues]
{queues}
z
[tasks]
{tasks}
cCs ddlm}tdd�|�D��S)Nr��	enumeratecss|]}|j�d�sdVqdS)zDummy-�N)�name�
startswith)�.0�t�r(�</usr/local/lib/python3.9/site-packages/celery/apps/worker.py�	<genexpr>Ls�z&active_thread_count.<locals>.<genexpr>)�	threadingr"�sumr!r(r(r)�active_thread_countJsr-cCs6t|d�r2|��dur2t�|��d|�d����dS)N�fileno�
)�hasattrr.�os�write�encode)�msg�fr(r(r)�safe_sayPsr6cs�eZdZdZd#dd�Zd$�fdd�	Zdd	�Z�fd
d�Zdd
�Zdd�Z	d%dd�Z
dd�Zd&dd�Zdd�Z
d'dd�Zdd�Zdd �Zd!d"�Z�ZS)(rzWorker as a program.FcKsB||_t�|j|j�tjj|j||jj|d�t	|jjj
�dS)N)�sender�instance�conf�options)�quietr
�setup_worker_optimizations�app�hostnamer	Zceleryd_init�sendr9rZaccept_content)�selfr;�kwargsr(r(r)�on_before_initXs�zWorker.on_before_initNcsr|j�d|�|_|j�d|�|_t�jfi|��||_||_tt	j
�|_|jjj
|j|durd|n|d�|_
dS)NZworker_redirect_stdoutsZworker_redirect_stdouts_level)�enabled)r=Zeither�redirect_stdouts�redirect_stdouts_level�superZsetup_defaults�purge�no_colorr�sys�stdout�_isatty�log�colored�logfile)r@rGrHrDrErA��	__class__r(r)�
on_after_initds���zWorker.on_after_initcCs|��|_t�|j|j�dS�N)�
setup_logging�_custom_loggingr
r<r=r>�r@r(r(r)�on_init_blueprintts
zWorker.on_init_blueprintcs�|j}t���tjj|j||jd�|jr4|�	�|j
sB|��|�d�|�
|�|jsp|jrp|j�|j�d}|j}t|t�r�|��dv}|r�|j��r�t�d�dS)N)r7r8r9z-active-T)zdjango.conf:settingszPlease run `celery upgrade settings path/to/settings.py` to avoid these warnings and to allow a smoother upgrade to Celery 6.0.)r=rF�on_startr	Zceleryd_after_setupr?r>r9rG�purge_messagesr;�emit_banner�set_process_status�install_platform_tweaksrTrDrLrEZ_config_source�
isinstance�str�lowerZmaybe_warn_deprecated_settings�logger�warning)r@r=Zwarn_deprecatedZ
config_sourcerOr(r)rWzs,

�



�zWorker.on_startcCslt��}|rtt�t����ttd�t|j	�
d|j|d���t|j	�|�
�pRd��g��tjdd�dS)N�z 
)�artlinesT)�file�flush)rZsupports_images�printZimgcatrZlogor�joinr]rM�cyan�startup_info�reset�
extra_inforI�
__stdout__)r@Z	use_imager(r(r)rY�s���zWorker.emit_bannercCs$tjj|d�t�dt|j��dS)N)r7z	%s ready.)r	Zworker_readyr?r_�inforr>)r@�consumerr(r(r)�on_consumer_ready�szWorker.on_consumer_readycCs8|dur|jdur|j}|jjj|j|jd||jd�S)NF)rD�colorizer>)rHr=rL�setup�loglevelrNr>)r@ror(r(r)rS�s�zWorker.setup_loggingcCsb|j���D}|jjj|d�}|r@td|�dt|d��d�dd�Wd�n1sT0YdS)N)�
connectionzpurge: Erased � �messagez from the queue.
T)rd)r=Zconnection_for_write�controlrGrer)r@rr�countr(r(r)rX�szWorker.purge_messagesTr/�celery.cs"|���fdd�t|jj�D��S)Nc3s,|]$}�s|���sn|rd|��VqdS)z  . N)r%)r&�task��include_builtins�int_r(r)r*�s�z"Worker.tasklist.<locals>.<genexpr>)rf�sortedr=�tasks)r@rz�sepr{r(ryr)�tasklist�s
�zWorker.tasklistcCsB|jdurdS|jtjkr>|jtjk}|j|d�}tj|d�SdS)N)rz)r})rq�logging�INFO�DEBUGr�EXTRA_INFO_FMT�format)r@rzrr(r(r)rj�s
zWorker.extra_infoc
Cs�|j}t|j�}d�|jpdt|��}t|jt�sbt	|j�}|�
d�rR|dd�}|d|�d�7}|jr�|j\}}d|�d|�d	�}|j}t|t�s�|j
}|d|�d
�d�d�7}d}	|js�d
}	tj|t|j�t��jdd�t|j����|jj��|tt���|	|jjjddd�d�
��}
|�r|t|
�D]N\}}zd� t!||
|g�|
|<Wn$t"�yvd|
||
|<Yn0�q,d� |
�dS)Nz{}:{:#x}�__main__zcelery.loaders�� (�)z{min=z, max=�}�.����ONz/OFF (enable -E to monitor tasks in this worker)r)�microsecondF)�indent�indent_first)
r=r>�	timestamp�versionZconninfo�results�concurrency�platform�events�queuesrsz                r/)#r=r]r�r��main�idr\�loaderrrr%Z	autoscale�pool_cls�
__module__�splitZtask_events�BANNERrr>r�now�replacerrr�as_uri�backend�	_platformr�Zamqpr��
splitlinesr"rf�ARTLINES�
IndexError)
r@rbr=r�Zapprr��max�min�poolr�Zbanner�i�_r(r(r)rh�sJ






�
zWorker.startup_infocCsX|jjr|��|js0|jjr(t|�nt|�t|�t|�t|�t	�t
�dS)z1Install platform specific tweaks and workarounds.N)r=ZIS_macOS� macOS_proxy_detection_workaroundrK�!install_HUP_not_supported_handler�install_worker_restart_handler�install_worker_term_handler� install_worker_term_hard_handler�install_worker_int_handler�install_cry_handler�install_rdb_handler)r@�workerr(r(r)r[�s
zWorker.install_platform_tweakscCstj�dd�dS)z6See https://github.com/celery/celery/issues#issue/161.Zcelery_dummy_proxyZset_by_celerydN)r1�environ�
setdefaultrUr(r(r)r�sz'Worker.macOS_proxy_detection_workaroundcCs&tjd|�dt�tj��d�|jd�S)NZcelerydr�r�)rlr>)rZset_mp_process_titleZstrargvrI�argvr>)r@rlr(r(r)rZs
�zWorker.set_process_status)F)FNNN)N)Tr/rw)T)�__name__r��__qualname__�__doc__rBrQrVrWrYrnrSrXrrjrhr[r�rZ�
__classcell__r(r(rOr)rUs"
�(


*r�SIGTERM�WarmT�r�cs4������fdd�}td����|_|tj�<dS)a<Install signal handler for warm/cold shutdown.

    The handler will run from the MainProcess.

    Args:
        worker (Worker): The worker that received the signal.
        sig (str, optional): The signal that was received. Defaults to 'TERM'.
        how (str, optional): The type of shutdown to perform. Defaults to 'Warm'.
        callback (Callable, optional): Signal handler. Defaults to None.
        exitcode (int, optional): The exit code to use. Defaults to EX_OK.
        verbose (bool, optional): Whether to print the type of shutdown. Defaults to True.
    cs�t��xddlm}t�jdkrZ�r,����rDtd��d�tj�tj	j
�j���d�t|ddd	����Wd�n1s�0YdS)
Nr��state�MainProcesszworker: z shutdown (MainProcess))r7�sig�how�exitcode�should_stopZshould_terminate)r��Cold)
r�
celery.workerr�r�_namer6rIrkr	Zworker_shutting_downr?r>�setattr)�argsr���callbackr�r�r��verboser�r(r)�_handle_request's$����z*_shutdown_handler.<locals>._handle_requestZworker_N)r]r�rr	)r�r�r�r�r�r�r�r(r�r)�_shutdown_handlers
r�cCsddlm}|t��dS)auSignal handler for hard shutdown.

    The handler will terminate the worker immediately by force using the exit code ``EX_FAILURE``.

    In practice, you should never get here, as the standard shutdown process should be enough.
    This handler is only for the worst-case scenario, where the worker is stuck and cannot be
    terminated gracefully (e.g., spamming the Ctrl+C in the terminal to force the worker to terminate).

    Args:
        worker (Worker): The worker that received the signal.

    Raises:
        WorkerTerminate: This exception will be raised in the MainProcess to terminate the worker immediately.
    r)�WorkerTerminateN)Zcelery.exceptionsr�r)r�r�r(r(r)�on_hard_shutdown9sr�cCs8t|dtdd�t|dtd�|j��tdtj�dS)amThis signal handler is called when the worker is in the middle of the soft shutdown process.

    When the worker is in the soft shutdown process, it is waiting for tasks to finish. If the worker
    receives a SIGINT (Ctrl+C) or SIGQUIT signal (or possibly SIGTERM if REMAP_SIGTERM is set to "SIGQUIT"),
    the handler will cancels all unacked requests to allow the worker to terminate gracefully and replace the
    signal handler for SIGINT and SIGQUIT with the hard shutdown handler ``on_hard_shutdown`` to terminate
    the worker immediately by force next time the signal is received.

    It will give the worker once last chance to gracefully terminate (the cold shutdown), after canceling all
    unacked requests, before using the hard shutdown handler to terminate the worker forcefully.

    Args:
        worker (Worker): The worker that received the signal.
    �SIGINTF)r�r�r��SIGQUIT�r�r�z3Waiting gracefully for cold shutdown to complete...N)r�r�rm�cancel_all_unacked_requestsr6rIrkr�r(r(r)�during_soft_shutdownLs
r�cCs`tdtj�t|dtd�t|dtd�tdkr>t|dtd�|��|j��|jj	�
�dS)aZ	Signal handler for cold shutdown.

    Registered for SIGQUIT and SIGINT (Ctrl+C) signals. If REMAP_SIGTERM is set to "SIGQUIT", this handler will also
    be registered for SIGTERM.

    This handler will initiate the cold (and soft if enabled) shutdown procesdure for the worker.

    Worker running with N tasks:
        - SIGTERM:
            -The worker will initiate the warm shutdown process until all tasks are finished. Additional.
            SIGTERM signals will be ignored. SIGQUIT will transition to the cold shutdown process described below.
        - SIGQUIT:
            - The worker will initiate the cold shutdown process.
            - If the soft shutdown is enabled, the worker will wait for the tasks to finish up to the soft
            shutdown timeout (practically having a limited warm shutdown just before the cold shutdown).
            - Cancel all tasks (from the MainProcess) and allow the worker to complete the cold shutdown
            process gracefully.

    Caveats:
        - SIGINT (Ctrl+C) signal is defined to replace itself with the cold shutdown (SIGQUIT) after first use,
        and to emit a message to the user to hit Ctrl+C again to initiate the cold shutdown process. But, most
        important, it will also be caught in WorkController.start() to initiate the warm shutdown process.
        - SIGTERM will also be handled in WorkController.start() to initiate the warm shutdown process (the same).
        - If REMAP_SIGTERM is set to "SIGQUIT", the SIGTERM signal will be remapped to SIGQUIT, and the cold
        shutdown process will be initiated instead of the warm shutdown process using SIGTERM.
        - If SIGQUIT is received (also via SIGINT) during the cold/soft shutdown process, the handler will cancel all
        unacked requests but still wait for the soft shutdown process to finish before terminating the worker
        gracefully. The next time the signal is received though, the worker will terminate immediately by force.

    So, the purpose of this handler is to allow waiting for the soft shutdown timeout, then cancel all tasks from
    the MainProcess and let the WorkController.terminate() to terminate the worker naturally. If the soft shutdown
    is disabled, it will immediately cancel all tasks let the cold shutdown finish normally.

    Args:
        worker (Worker): The worker that received the signal.
    z>worker: Hitting Ctrl+C again will terminate all running tasks!r�r�r�r�N)r6rIrkr�r�rZwait_for_soft_shutdownrmr�r��stopr�r(r(r)�on_cold_shutdownks%
r�r�r�)r�r�r�r�)r�r�cOsdSrRr()�a�kwr(r(r)�<lambda>��r�cCstdtj�t|ddd�dS)NzXworker: Hitting Ctrl+C again will initiate cold shutdown, terminating all running tasks!r�F)r�r�)r6rIrkr�r�r(r(r)�	on_SIGINT�s�r�r�)r�r�r�cOsdSrRr()r�rAr(r(r)r��sr�cCs2t�tjtjtjg�t�tjtjgtj	�dSrR)
rZclose_open_fdsrI�	__stdin__rk�
__stderr__r1�execv�
executabler�r(r(r(r)�_reload_current_worker�s�r��SIGHUPcCsdd�}|tj|<dS)NcWsLtd�tdd�tj��d�tj�ddl}|�t�ddl	m
}t|_dS)z5Signal handler restarting the current python program.TzRestarting celery worker (rsr�rNr�)
rr6rfrIr�rk�atexit�registerr�r�r�r
r�)r�r�r�r(r(r)�restart_worker_sig_handler�s�
zBinstall_worker_restart_handler.<locals>.restart_worker_sig_handler�rr	)r�r�r�r(r(r)r��s	r��SIGUSR1cCstrdSdd�}|tj|<dS)NcWs4t��tt��Wd�n1s&0YdS)z=Signal handler logging the stack-trace of all active threads.N)rr6r)r�r(r(r)�cry_handler�sz(install_cry_handler.<locals>.cry_handler)�is_pypyrr	)r�r�r(r(r)r��sr��
CELERY_RDBSIG�SIGUSR2cCs"dd�}tj�|�r|tj|<dS)NcWsVt��<ddlm}m}|r$|dn|�j}||�Wd�n1sH0YdS)z=Signal handler setting a rdb breakpoint at the current frame.r)�_frame�	set_tracer#N)rZcelery.contrib.rdbr�r��f_back)r�r�r��framer(r(r)�rdb_handler�sz(install_rdb_handler.<locals>.rdb_handler)r1r��getrr	)Zenvvarr�r�r(r(r)r��sr�cs�fdd�}|tj�<dS)Ncs:t�� tdj�d��Wd�n1s,0YdS)NzH{sig} not supported: Restarting with {sig} is unstable on this platform!�r�)rr6r�)�signumr�r�r(r)�warn_on_HUP_handler�s�z>install_HUP_not_supported_handler.<locals>.warn_on_HUP_handlerr�)r�r�r�r(r�r)r��sr�)r�)r�)r�r�)r�)Fr�r�r1r�r�rIr�	functoolsrZbilliard.commonrZbilliard.processrZkombu.utils.encodingrZceleryrrr	Z
celery.appr
Zcelery.loaders.apprZcelery.platformsrr
rrZcelery.utilsrrZcelery.utils.debugrZcelery.utils.importsrZcelery.utils.logrrrZcelery.utils.textrr�r�__all__r�r_r%Z	is_jythonr0r�r�r�r�r-r�r6rr�r�r�r�r�r�r�r�r�r�r�r�r�r(r(r(r)�<module>s|
F9

��
���

�