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/worker/__pycache__/autoscale.cpython-39.pyc
a

X>h��@s�dZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZddlm
Z
dd	lmZdd
lmZdZee�ZejejejZZZeej�dd
��ZGdd�de	j�ZGdd�de
�ZdS)z�Pool Autoscaling.

This module implements the internal thread responsible
for growing and shrinking the pool according to the
current autoscale settings.

The autoscale thread is only enabled if
the :option:`celery worker --autoscale` option is used.
�N)�	monotonic�sleep)�	DummyLock)�	bootsteps)�
get_logger)�bgThread�)�state)�Pool)�
Autoscaler�WorkerComponent�AUTOSCALE_KEEPALIVE�c@s>eZdZdZdZdZefZdd�Zdd�Z	dd	�Z
d
d�ZdS)
rz?Bootstep that starts the autoscaler thread/timer in the worker.rTcKs|j|_d|_dS�N)Z	autoscale�enabled�
autoscaler)�self�w�kwargs�r�A/usr/local/lib/python3.9/site-packages/celery/worker/autoscale.py�__init__&szWorkerComponent.__init__cCs>|j|j|j|j|j||jr"t�ndd�}|_|js:|SdS)N)�worker�mutex)ZinstantiateZautoscaler_cls�pool�max_concurrency�min_concurrencyZ
use_eventlooprr)rrZscalerrrr�create*s�zWorkerComponent.createcCs*|jj�|jj�|�|jj|jj�dSr)�consumerZon_task_message�addr�maybe_scaleZcall_repeatedly�	keepalive)rrZhubrrr�register_with_event_loop2s�z(WorkerComponent.register_with_event_loopcCsd|j��iS)zReturn `Autoscaler` info.r)r�info)rrrrrr#8szWorkerComponent.infoN)�__name__�
__module__�__qualname__�__doc__�labelZconditionalr
�requiresrrr"r#rrrrrsrcs�eZdZdZddedf�fdd�	Zdd�Zddd	�Zdd
d�Zd dd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zedd��Zedd��Z�ZS)!rz,Background thread to autoscale pool workers.rNcsNt���||_|pt��|_||_||_||_d|_	||_
|jsJJd��dS)Nzcannot scale down too fast.)�superrr�	threading�Lockrrrr!�_last_scale_upr)rrrrrr!r��	__class__rrr@s
zAutoscaler.__init__cCs:|j�|��Wd�n1s$0Ytd�dS)Ng�?)rr r�rrrr�bodyNs&zAutoscaler.bodycCsZ|j}t|j|j�}||kr.|�||�dSt|j|j�}||krV|�||�dSdS)NT)�	processes�min�qtyr�scale_up�maxr�
scale_down)r�reqZprocs�currrr�_maybe_scaleSszAutoscaler._maybe_scalecCs|�|�r|j��dSr)r:rZ
maintain_pool)rr8rrrr ^s
zAutoscaler.maybe_scalecCs�|j�v|dur:||jkr*|�|j|�|�|�||_|durb||jkr\|�||j�||_|j|jfWd�S1s�0YdSr)rr2�_shrink�_update_consumer_prefetch_countr�_growr)rr6r3rrr�updatebs


zAutoscaler.updatecCst�|_|�|�Sr)rr-r=�r�nrrrr5oszAutoscaler.scale_upcCs&|jr"t�|j|jkr"|�|�SdSr)r-rr!r;r?rrrr7ss�zAutoscaler.scale_downcCstd|�|j�|�dS)NzScaling up %s processes.)r#rZgrowr?rrrr=xs
zAutoscaler._growc
Csjtd|�z|j�|�WnJty4td�Yn2tyd}ztd|dd�WYd}~n
d}~00dS)NzScaling down %s processes.z0Autoscaler won't scale down: all processes busy.zAutoscaler: scale_down: %rT)�exc_info)r#r�shrink�
ValueError�debug�	Exception�error)rr@�excrrrr;|s
zAutoscaler._shrinkcCs ||j}|r|jj�|�dSr)rrrZ_update_prefetch_count)rZnew_max�diffrrrr<�s

�z*Autoscaler._update_consumer_prefetch_countcCs|j|j|j|jd�S)N)r6r3�currentr4)rrr2r4r0rrrr#�s
�zAutoscaler.infocCs
ttj�Sr)�lenr	Zreserved_requestsr0rrrr4�szAutoscaler.qtycCs|jjSr)rZ
num_processesr0rrrr2�szAutoscaler.processes)N)N)NN)r$r%r&r'r
rr1r:r r>r5r7r=r;r<r#�propertyr4r2�
__classcell__rrr.rr=s$�



	
r)r'�osr+�timerrZkombu.asynchronous.semaphorerZceleryrZcelery.utils.logrZcelery.utils.threadsr�r	�
componentsr
�__all__r$�loggerrDr#rF�float�environ�getr
Z
StartStopSteprrrrrr�<module>s