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/asynchronous/__pycache__/semaphore.cpython-39.pyc
a

X>h�
�@s�dZddlmZddlZddlmZddlmZer|ddlm	Z	ddlm
Z
mZejdkrhdd	l
mZndd	lmZed
�ZdZGdd
�d
�ZGdd�d�ZdS)z&Semaphores and concurrency primitives.�)�annotationsN)�deque)�
TYPE_CHECKING)�
TracebackType)�Callable�Deque)��
)�	ParamSpec�P)�	DummyLock�LaxBoundedSemaphorec@s�eZdZdZddd�dd�Zddd	d
d�dd
�Zdd�dd�Zdddd�dd�Zdddd�dd�Zdd�dd�Z	dd�dd�Z
dS)r
a�Asynchronous Bounded Semaphore.

    Lax means that the value will stay within the specified
    range even if released more times than it was acquired.

    Example:
    -------
        >>> x = LaxBoundedSemaphore(2)

        >>> x.acquire(print, 'HELLO 1')
        HELLO 1

        >>> x.acquire(print, 'HELLO 2')
        HELLO 2

        >>> x.acquire(print, 'HELLO 3')
        >>> x._waiters   # private, do not access directly
        [print, ('HELLO 3',)]

        >>> x.release()
        HELLO 3
    �int�None)�value�returncCs,||_|_t�|_|jj|_|jj|_dS�N)�
initial_valuerr�_waiting�append�_add_waiter�popleft�_pop_waiter)�selfr�r�F/usr/local/lib/python3.9/site-packages/kombu/asynchronous/semaphore.py�__init__-s
zLaxBoundedSemaphore.__init__zCallable[P, None]zP.argszP.kwargs�bool)�callback�partial_args�partial_kwargsrcOsH|j}|dkr"|�|||f�dSt|dd�|_||i|��dSdS)a^Acquire semaphore.

        This will immediately apply ``callback`` if
        the resource is available, otherwise the callback is suspended
        until the semaphore is released.

        Arguments:
        ---------
            callback (Callable): The callback to apply.
            *partial_args (Any): partial arguments to callback.
        rF�TN)rr�max)rrrr rrrr�acquire3szLaxBoundedSemaphore.acquire�rcCsLz|��\}}}Wn&ty8t|jd|j�|_Yn0||i|��dS)z�Release semaphore.

        Note:
        ----
            If there are any waiters this will apply the first waiter
            that is waiting for the resource (FIFO order).
        r!N)r�
IndexError�minrr)r�waiter�args�kwargsrrr�releaseMs
zLaxBoundedSemaphore.releaser!)�nrcCs6|j|7_|j|7_t|�D]}|��q$dS)z6Change the size of the semaphore to accept more users.N)rr�ranger*)rr+�_rrr�grow\szLaxBoundedSemaphore.growcCs(t|j|d�|_t|j|d�|_dS)z6Change the size of the semaphore to accept less users.rN)r"rr)rr+rrr�shrinkcszLaxBoundedSemaphore.shrinkcCs|j��|j|_dS)z@Reset the semaphore, which also wipes out any waiting callbacks.N)r�clearrr�rrrrr0hs
zLaxBoundedSemaphore.clear�strcCs d�|jjt|�|jt|j��S)Nz!<{} at {:#x} value:{} waiting:{}>)�format�	__class__�__name__�idr�lenrr1rrr�__repr__ms�zLaxBoundedSemaphore.__repr__N)r!)r!)r5�
__module__�__qualname__�__doc__rr#r*r.r/r0r8rrrrr
sr
c@s2eZdZdZdd�dd�Zddddd	�d
d�ZdS)
rzPretending to be a lock.r$cCs|Srrr1rrr�	__enter__vszDummyLock.__enter__ztype[BaseException] | NonezBaseException | NonezTracebackType | Noner)�exc_type�exc_val�exc_tbrcCsdSrr)rr=r>r?rrr�__exit__yszDummyLock.__exit__N)r5r9r:r;r<r@rrrrrssr)r;�
__future__r�sys�collectionsr�typingr�typesrrr�version_infoZtyping_extensionsr
r�__all__r
rrrrr�<module>s
^