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/utils/__pycache__/debug.cpython-39.pyc
a

X>he�@sdZddlZddlZddlZddlmZddlmZddlmZddl	m
Z
ddlmZzddl
mZWney~dZYn0d	Zd
ZdagZdd�Zed
d��Zdd�Zd'dd�Zd(dd�Zd)dd�Zd*dd�Zdd�Zdd�Zdd �Zd!d"�Zd+d%d&�ZdS),z:Utilities for debugging memory usage, blocking calls, etc.�N)�contextmanager)�partial)�pprint)�signals)�
WhateverIO)�Process)�blockdetection�
sample_mem�memdump�sample�
humanbytes�mem_rss�ps�cry))gpBZTB)g�AZGB)g0AZMB)g�@ZKB)g�bcCs ddl}td|�|�����dS)Nrz!Blocking detection timed-out at: )�inspect�RuntimeError�getframeinfo)�signum�framer�r�</usr/local/lib/python3.9/site-packages/celery/utils/debug.py�_on_blocking"s�rc	csl|sdVn\td}|tkr dn|}ttd<z$t�|�VW|rH|td<t��n|r^|td<t��0dS)zqContext that raises an exception if process is blocking.

    Uses ``SIGALRM`` to detect blocking functions.
    NZALRM)rrZ	arm_alarmZreset_alarm)�timeoutZold_handlerrrrr)s
�rcCst�}t�|�|S)z\Sample RSS memory usage.

    Statistics can then be output by calling :func:`memdump`.
    )r
�_mem_sample�append)Zcurrent_rssrrrr	?s
r	�
cCsLt}t|�|krt|�nt||�}gtdd�<ddl}|��t�}||fS)Nr)r�len�listr�gcZcollectr
)�samples�S�prevr�
after_collectrrr�_memdumpIsr$cCshtt|d�}t�dur"|d�dSt|�\}}|rT|d�|D]}|d|�d��q>|d|�d��dS)	z�Dump memory statistics.

    Will print a sample of all RSS memory samples added by
    calling :func:`sample_mem`, and in addition print
    used RSS memory after :func:`gc.collect`.
    ��fileNz- rss: (psutil not installed).z- rss (sample):z-    > �,z
- rss (end): �.)r�printrr$)r r&Zsayr"r#Zmemrrrr
Ss
r
c	csNt|�|}t|�D]4}z||VWnty>YqJYn0||7}qdS)z�Given a list `x` a sample of length ``n`` of that list is returned.

    For example, if `n` is 10, and `x` has 100 items, a list of every tenth.
    item is returned.

    ``k`` can be used as offset.
    N)r�range�
IndexError)�x�n�k�j�_rrrrfsr�cCs"t|�}||kr|Sdj||d�S)z�Convert float to value suitable for humans.

    Arguments:
        f (float): The floating point number.
        p (int): Floating point precision (default is 5).
    z{0:.{p}}��p)�int�format)�fr3�irrr�hfloatwsr8cst�fdd�tD��S)z4Convert bytes to human-readable form (e.g., KB, MB).c3s6|].\}}�|krt|r �|n���|��VqdS�N)r8)�.0�div�unit��srr�	<genexpr>�s�zhumanbytes.<locals>.<genexpr>)�next�UNITSr=rr=rr�s�rcCs t�}|durtt|�j�SdS)z.Return RSS memory usage as a humanized string.N)rr�_process_memory_infoZrssr2rrrr
�sr
cCs tdurtdurtt���atS)z�Return the global :class:`psutil.Process` instance.

    Note:
        Returns :const:`None` if :pypi:`psutil` is not installed.
    N)�_processr�os�getpidrrrrr�srcCs*z
|��WSty$|��YS0dSr9)Zmemory_info�AttributeErrorZget_memory_info)�processrrrrB�s
rB�=�1c
Cs�ddl}|durt�n|}tt|d�}dd�|��D�}||}t����D]h\}}|�|�}	|	sdqL||	j	��||�t
j||d�||�|d�||�t|j
|d�|d�qL|��S)	zpReturn stack-trace of all active threads.

    See Also:
        Taken from https://gist.github.com/737056.
    rNr%cSsi|]}|j|�qSr)�ident)r:�trrr�
<dictcomp>��zcry.<locals>.<dictcomp>zLOCAL VARIABLES)�stream�
)�	threadingrrr)�	enumerate�sys�_current_frames�items�get�name�	traceback�print_stackr�f_locals�getvalue)
�outZsepchr�seplenrP�PZtmap�sep�tidr�threadrrrr�s$

r)r)rN)r)r1)NrHrI) �__doc__rDrRrW�
contextlibr�	functoolsrrZcelery.platformsrZcelery.utils.textrZpsutilr�ImportError�__all__rArCrrrr	r$r
rr8rr
rrBrrrrr�<module>s: