o
    .&ßa«  ã                   @   s    d Z ddlZG dd„ deƒ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   ú8/usr/lib/python3/dist-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 )zýAttempt 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 )z­Release 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_capacity7   s   zRetryQuota.available_capacity)	Ú__name__Ú
__module__Ú__qualname__ÚINITIAL_CAPACITYr   r   r   Úpropertyr   r   r   r   r   r      s    r   )Ú__doc__r   Úobjectr   r   r   r   r   Ú<module>   s    