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/kombu/__pycache__/resource.cpython-39.pyc
a

X>h��@s�dZddlmZddlZddlmZddlmZddlmZ	ddl
mZdd	lm
Z
dd
lmZddlmZer|ddlmZd
d�ZGdd�de	�ZGdd�d�ZdS)z%Generic resource pool implementation.�)�annotationsN)�deque)�Empty)�	LifoQueue)�
TYPE_CHECKING�)�
exceptions)�register_after_fork)�lazy)�
TracebackTypecCs$z|��WntyYn0dS�N)�force_close_all�	Exception)�resource�r�8/usr/local/lib/python3.9/site-packages/kombu/resource.py�_after_fork_cleanup_resourcesrc@seZdZdZdd�ZdS)rz#Last in first out version of Queue.cCst�|_dSr)r�queue)�self�maxsizerrr�_initszLifoQueue._initN)�__name__�
__module__�__qualname__�__doc__rrrrrrsrc@s�eZdZdZejZdZd&dd�Zdd�Zdd	�Z	d'd
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd(dd�Zd)dd�Zd*dd�Zedd ��Zejd!d ��Zej�d"�r�e
ZeZd#Zd$d�Z
d%d�ZdS)+�ResourcezPool of resources.FNcCs^||_|pd|_d|_|dur"|n|j|_t�|_t�|_|jrRtdurRt|t	�|�
�dS)NrF)�_limit�preload�_closed�close_after_forkr�	_resource�set�_dirtyr	r�setup)r�limitrrrrr�__init__(s
��
zResource.__init__cCstd��dS)Nzsubclass responsibility)�NotImplementedError�rrrrr#7szResource.setupcCs6|jr"t|j�|jkr"|�|j��|j�|���dSr)r$�lenr"�
LimitExceededr �
put_nowait�newr'rrr�_add_when_empty:szResource._add_when_emptycs��jrtd���jr�z�jj||d��WntyB���Yq0z�����Wn6ty�t	�t
�rx�j���n
�����Yn0�j
���q�qn���������fdd�}|�_�S)a�Acquire resource.

        Arguments:
        ---------
            block (bool): If the limit is exceeded,
                then block until there is an available item.
            timeout (float): Timeout to wait
                if ``block`` is true.  Default is :const:`None` (forever).

        Raises
        ------
            LimitExceeded: if block is false and the limit has been exceeded.
        zAcquire on closed pool)�block�timeoutcs����dS)a'Release resource so it can be used by another thread.

            Warnings:
            --------
                The caller is responsible for discarding the object,
                and to never use the resource again.  A new resource must
                be acquired if so needed.
            N)�releaser��Rrrrr/hs	z!Resource.acquire.<locals>.release)r�RuntimeErrorr$r �getrr,�prepare�
BaseException�
isinstancer
r*r/r"�addr+)rr-r.r/rr0r�acquireBs(


zResource.acquirecCs|Srr�rrrrrr4vszResource.preparecCs|��dSr)�closer9rrr�close_resourceyszResource.close_resourcecCsdSrrr9rrr�release_resource|szResource.release_resourcecCs |jr|j�|�|�|�dS)zqReplace existing resource with a new instance.

        This can be used in case of defective resources.
        N)r$r"�discardr;r9rrr�replaceszResource.replacecCs8|jr*|j�|�|j�|�|�|�n
|�|�dSr)r$r"r=r r*r<r;r9rrrr/�s
zResource.releasecCsdSrrr9rrr�collect_resource�szResource.collect_resourceTcCs�|jr
dS||_|j}|j}z|��}Wnty>YqdYn0z|�|�Wqty`Yq0qz|j��}Wnty�Yq�Yn0z|�|�Wqdty�Yqd0qddS)aaClose and remove all resources in the pool (also those in use).

        Used to close resources from parent processes after fork
        (e.g. sockets/connections).

        Arguments:
        ---------
            close_pool (bool): If True (default) then the pool is marked
                as closed. In case of False the pool can be reused.
        N)	rr"r �pop�KeyErrorr?�AttributeErrorr�
IndexError)r�
close_poolZdirtyrZdres�resrrrr
�s*

zResource.force_close_allcCs�|j}|jrDd|kr"|jkrDnn|sD|s@td�|j|���d}||_|rrz|jdd�WntypYn0|��||kr�|j|dkd�dS)Nrz,Can't shrink pool when in use: was={} now={}TF)rD)�collect)rr"r2�formatr
rr#�_shrink_down)rr$�force�
ignore_errors�resetZ
prev_limitrrr�resize�s$$��zResource.resizecCs�Gdd�d�}|j}t|d|���Nt|j�rbt|j�t|j�|jkrb|j��}|r$|�|�q$Wd�n1sv0YdS)Nc@s(eZdZdd�Zddddd�dd	�Zd
S)z#Resource._shrink_down.<locals>.NoopcSsdSrrr'rrr�	__enter__�sz-Resource._shrink_down.<locals>.Noop.__enter__�typerr�None)�exc_type�exc_val�exc_tb�returncSsdSrr)rrPrQrRrrr�__exit__�sz,Resource._shrink_down.<locals>.Noop.__exit__N)rrrrMrTrrrr�Noop�srU�mutex)r �getattrr(rr"r$�popleftr?)rrFrUrr1rrrrH�s
�
zResource._shrink_downcCs|jSr)rr'rrrr$�szResource.limitcCs|�|�dSr)rL)rr$rrrr$�sZKOMBU_DEBUG_POOLrcOs�ddl}|jd}|_td|�d|jj���|j|i|��}||_td|�d|jj���t|d�sng|_|j�	|�
��|S)Nrr�+z	 ACQUIRE �-�acquired_by)�	traceback�_next_resource_id�print�	__class__r�
_orig_acquire�_resource_id�hasattrr[�append�format_stack)r�args�kwargsr\�id�rrrrr8�s
cCsR|j}td|�d|jj���|�|�}td|�d|jj���|jd8_|S)NrYz	 RELEASE rZr)rar^r_r�
_orig_releaser])rrrgrhrrrr/�s
)NNN)FN)T)FFF)T)rrrrrr)rr%r#r,r8r4r;r<r>r/r?r
rLrH�propertyr$�setter�os�environr3r`rir]rrrrr!s4

4	
&



r)r�
__future__rrl�collectionsrrrrZ
_LifoQueue�typingr�rZutils.compatr	Zutils.functionalr
�typesrrrrrrr�<module>s