
    Pe                     $    d Z ddlZ G d d      Zy)zRetry quota implementation.


    Nc                   8    e Zd ZdZedfdZd Zd Zed        Zy)
RetryQuotai  Nc                 Z    || _         || _        |t        j                         }|| _        y N)_max_capacity_available_capacity	threadingLock_lock)selfinitial_capacitylocks      8/usr/lib/python3/dist-packages/botocore/retries/quota.py__init__zRetryQuota.__init__   s*    -#3 <>>#D
    c                     | j                   5  || j                  kD  r
	 ddd       y| xj                  |z  c_        	 ddd       y# 1 sw Y   yxY w)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_amounts     r   acquirezRetryQuota.acquire   sQ     ZZ 	!9!99	 	 $$7$		 	 	s   AAAc                     | j                   | j                  k(  ry| j                  5  t        | j                   | j                  z
  |      }| xj                  |z  c_        ddd       y# 1 sw Y   yxY w)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   amounts      r   releasezRetryQuota.release"   sj     !9!99ZZ 	/""T%=%==F $$.$		/ 	/ 	/s   9A))A2c                     | j                   S r   )r   )r   s    r   available_capacityzRetryQuota.available_capacity6   s    '''r   )	__name__
__module____qualname__INITIAL_CAPACITYr   r   r   propertyr    r   r   r   r      s0    (8t  /( ( (r   r   )__doc__r	   r   r    r   r   <module>r"      s    0( 0(r   