HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/botocore/retries/__pycache__/bucket.cpython-310.pyc
o

.&�a��@sDdZddlZddlZddlmZGdd�de�ZGdd�de�ZdS)zEThis module implements token buckets used for client side throttling.�N)�CapacityNotAvailableErrorc@s$eZdZdd�Zdd�Zdd�ZdS)�ClockcCsdS�N���selfrr�9/usr/lib/python3/dist-packages/botocore/retries/bucket.py�__init__	szClock.__init__cCst�|�dSr)�time�sleep�r�amountrrrrszClock.sleepcCst��Sr)r
rrrr�current_timeszClock.current_timeN)�__name__�
__module__�__qualname__r	rrrrrrrsrc@speZdZdZefdd�Zedd��Zejdd��Zedd��Zed	d
��Z	dd
d�Z
dd�Zdd�Zdd�Z
dS)�TokenBucketg�?cCsFd|_d|_d|_||_d|_||_t��|_t�	|j�|_
||_dS)Nr)�
_fill_rate�
_max_capacity�_current_capacity�_clock�_last_timestamp�	_min_rate�	threading�Lock�_lock�	Condition�_new_fill_rate_condition�max_rate)rr�clock�min_raterrrr	s

zTokenBucket.__init__cC�|jSr)rrrrrr"�zTokenBucket.max_ratecCsr|j�,|��t||j�|_|dkr||_nd|_t|j|j�|_|j��Wd�dS1s2wYdS)N�)	r�_refill�maxrrr�minr�notify)r�valuerrrr&s�"�cCr!r)rrrrr�max_capacity<r"zTokenBucket.max_capacitycCr!r)rrrrr�available_capacity@r"zTokenBucket.available_capacityr#TcCs8|j�|j||d�Wd�S1swYdS)aJAcquire token or return amount of time until next token available.

        If block is True, then this method will block until there's sufficient
        capacity to acquire the desired amount.

        If block is False, then this method will return True is capacity
        was successfully acquired, False otherwise.

        )r
�blockN)r�_acquire)rr
r+rrr�acquireDs
$�zTokenBucket.acquirecCsx|��||jkr|j|8_dS|st��|�|�}|dkr3|j�|�|��|�|�}|dks |j|8_dS)NTr)r$rr�
_sleep_amountr�wait)rr
r+�sleep_amountrrrr,Qs


�
zTokenBucket._acquirecCs||j|jSr)rrrrrrr.hszTokenBucket._sleep_amountcCsT|j��}|jdur||_dS|j}||j|j}t|j||�}||_||_dSr)rrrrrr&r)r�	timestamp�current_capacity�fill_amount�new_capacityrrrr$ks


zTokenBucket._refillN)r#T)rrr�	_MIN_RATEr	�propertyr�setterr)r*r-r,r.r$rrrrrs





r)�__doc__r
r�botocore.exceptionsr�objectrrrrrr�<module>s