o
    Vf                     @   s   d Z ddlZG dd dZdS )zRetry quota implementation.    Nc                   @   s:   e Zd ZdZedfddZdd Zdd Zed	d
 ZdS )
RetryQuotai  Nc                 C   s&   || _ || _|d u rt }|| _d S N)_max_capacity_available_capacity	threadingLock_lock)selfinitial_capacitylock r   W/home/ubuntu/oakencloud.com/venv/lib/python3.10/site-packages/botocore/retries/quota.py__init__	   s
   
zRetryQuota.__init__c                 C   sX   | j  || jkr	 W d   dS |  j|8  _	 W d   dS 1 s%w   Y  dS )zAttempt to aquire a certain amount of capacity.

        If there's not sufficient amount of capacity available, ``False``
        is returned.  Otherwise, ``True`` is returned, which indicates that
        capacity was successfully allocated.

        NFT)r   r   )r	   capacity_amountr   r   r   acquire   s   

$zRetryQuota.acquirec                 C   s\   | j | jkrdS | j t| j | j |}|  j|7  _W d   dS 1 s'w   Y  dS )zRelease capacity back to the retry quota.

        The capacity being released will be truncated if necessary
        to ensure the max capacity is never exceeded.

        N)r   r   r   min)r	   r   amountr   r   r   release    s   "zRetryQuota.releasec                 C   s   | j S r   )r   )r	   r   r   r   available_capacity4   s   zRetryQuota.available_capacity)	__name__
__module____qualname__INITIAL_CAPACITYr   r   r   propertyr   r   r   r   r   r      s    r   )__doc__r   r   r   r   r   r   <module>   s    