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__/adaptive.cpython-310.pyc
o

.&�a�@srddlZddlZddlZddlmZddlmZddlmZe�e�Z	dd�Z
Gdd�de�ZGd	d
�d
e�Z
dS)�N)�bucket)�
throttling)�standardcCszt��}tjd|��d�}tjd|d�}t|�}tjt�	�d�}t
|||||d�}|jj�
d|j�|jj�
d|j�|S)	Nr)�starting_max_rate�
start_time�)�max_rate�clock)�retry_event_adapter)�
rate_adjustor�rate_clocker�token_bucket�throttling_detectorr	zbefore-sendzneeds-retry)r�Clockr�CubicCalculator�current_time�TokenBucket�RateClockerr�ThrottlingErrorDetector�RetryEventAdapter�ClientRateLimiter�meta�events�register�on_sending_request�on_receiving_response)�clientr	rr
rr�limiter�r�;/usr/lib/python3/dist-packages/botocore/retries/adaptive.py�register_retry_handler
s.�����r c@s(eZdZdZdd�Zdd�Zdd�ZdS)	rg@cCs2||_||_||_||_||_d|_t��|_dS)NF)	�_rate_adjustor�
_rate_clocker�
_token_bucket�_throttling_detector�_clock�_enabled�	threading�Lock�_lock)�selfrrr
rr	rrr�__init__*szClientRateLimiter.__init__cKs|jr
|j��dSdS�N)r&r#�acquire)r*�request�kwargsrrrr4s�z$ClientRateLimiter.on_sending_requestcKs�|j��}|j��}|j�D|jjdi|��s|j�|�}n!|j	s$|}nt
||jj�}|j�
||�}t�d|||jj�d|_	t
||j|�|j_Wd�dS1sTwYdS)NzfThrottling response received, new send rate: %s measured rate: %s, token bucket capacity available: %sTr)r"�recordr%rr)r$�is_throttling_errorr!�success_receivedr&�minr#r�error_received�logger�debug�available_capacity�_MAX_RATE_ADJUST_SCALE)r*r/�
measured_rate�	timestamp�new_rate�rate_to_userrrr9s(

��

�"�z'ClientRateLimiter.on_receiving_responseN)�__name__�
__module__�__qualname__r8r+rrrrrrr&s

rc@s<eZdZdZdZdZeefdd�Zddd�Zed	d
��Z	dS)
rz7Tracks the rate at which a client is sending a request.g�������?g�?cCsD||_d|_||_t�|j���|_d|j|_d|_	t
��|_dS)Nrr)
r%�_measured_rate�
_smoothing�math�floorr�_last_bucket�_TIME_BUCKET_RANGE�_time_bucket_scale�_countr'r(r))r*r	�	smoothing�time_bucket_rangerrrr+VszRateClocker.__init__rcCs�|j�E|j��}t�||j�|j}|j|7_||jkr>|jt||j�}||j	|j
d|j	|_
d|_||_|j
Wd�S1sKwYdS)Nrr)r)r%rrBrCrFrGrD�floatrAr@)r*�amount�tr�current_raterrrr0`s(
��
���$�zRateClocker.recordcCs|jSr,)r@)r*rrrr9qszRateClocker.measured_rateN)r)
r=r>r?�__doc__�_DEFAULT_SMOOTHINGrEr+r0�propertyr9rrrrrOs
�

r)rB�loggingr'�botocore.retriesrrr�	getLoggerr=r5r �objectrrrrrr�<module>s
)