Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/kombu/asynchronous/__pycache__/semaphore.cpython-39.pyc
Ðазад
a o�h� � @ s� d Z ddlmZ ddlZddlmZ ddlmZ er|ddlm Z ddlm Z mZ ejdk rhdd l mZ ndd lmZ ed �ZdZG dd � d �ZG dd� d�ZdS )z&Semaphores and concurrency primitives.� )�annotationsN)�deque)� TYPE_CHECKING)� TracebackType)�Callable�Deque)� � )� ParamSpec�P)� DummyLock�LaxBoundedSemaphorec @ s� e Zd ZdZddd�dd�Zddd d d�dd �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�returnc C s, | | _ | _t� | _| jj| _| jj| _d S �N)� initial_valuer r �_waiting�append�_add_waiter�popleft�_pop_waiter)�selfr � r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/kombu/asynchronous/semaphore.py�__init__- s zLaxBoundedSemaphore.__init__zCallable[P, None]zP.argszP.kwargs�bool)�callback�partial_args�partial_kwargsr c O sH | j }|dkr"| �|||f� dS t|d d�| _ ||i |�� dS dS )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. r F� TN)r r �max)r r r r r r r r �acquire3 s zLaxBoundedSemaphore.acquire�r c C sL z| � � \}}}W n& ty8 t| jd | j�| _Y n0 ||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�minr r )r �waiter�args�kwargsr r r �releaseM s zLaxBoundedSemaphore.releaser! )�nr c C s6 | j |7 _ | j|7 _t|�D ]}| �� q$dS )z6Change the size of the semaphore to accept more users.N)r r �ranger* )r r+ �_r r r �grow\ s zLaxBoundedSemaphore.growc C s( t | j| d�| _t | j| d�| _dS )z6Change the size of the semaphore to accept less users.r N)r"