HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/botocore/retries/__pycache__/adaptive.cpython-36.pyc
3

�T__�@srddlZddlZddlZddlmZddlmZddlmZeje�Z	dd�Z
Gdd�de�ZGd	d
�d
e�Z
dS)�N)�bucket)�
throttling)�standardcCsztj�}tjd|j�d�}tjd|d�}t|�}tjtj	�d�}t
|||||d�}|jjj
d|j�|jjj
d|j�|S)	Nr)Zstarting_max_rateZ
start_time�)�max_rate�clock)Zretry_event_adapter)�
rate_adjustor�rate_clocker�token_bucket�throttling_detectorrzbefore-sendzneeds-retry)rZClockrZCubicCalculator�current_timeZTokenBucket�RateClockerrZThrottlingErrorDetectorZRetryEventAdapter�ClientRateLimiter�metaZevents�register�on_sending_request�on_receiving_response)Zclientrrr
r	rZlimiter�r�/usr/lib/python3.6/adaptive.py�register_retry_handler
s$

rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	rg@cCs2||_||_||_||_||_d|_tj�|_dS)NF)	�_rate_adjustor�
_rate_clocker�
_token_bucket�_throttling_detector�_clock�_enabled�	threading�Lock�_lock)�selfrr	r
rrrrr�__init__*szClientRateLimiter.__init__cKs|jr|jj�dS)N)rr�acquire)rZrequest�kwargsrrrr4sz$ClientRateLimiter.on_sending_requestcKs�|jj�}|jj�}|j��|jjf|�s<d}|jj|�}nFd}|j	sL|}nt
||jj�}|jj
||�}tjd|||jj�d|_	t
||j|�|j_WdQRXdS)NFTzfThrottling response received, new send rate: %s measured rate: %s, token bucket capacity available: %s)r�recordrrrrZis_throttling_errorrZsuccess_receivedr�minrrZerror_received�logger�debugZavailable_capacity�_MAX_RATE_ADJUST_SCALE)rr"�
measured_rateZ	timestamprZnew_rateZrate_to_userrrr9s$


z'ClientRateLimiter.on_receiving_responseN)�__name__�
__module__�__qualname__r'r rrrrrrr&s
rc@s<eZdZdZdZdZeefdd�Zddd�Zed	d
��Z	dS)
r
z7Tracks the rate at which a client is sending a request.g�������?g�?cCsD||_d|_||_tj|jj��|_d|j|_d|_	t
j�|_dS)Nrr)
r�_measured_rate�
_smoothing�math�floorr�_last_bucket�_TIME_BUCKET_RANGE�_time_bucket_scale�_countrrr)rrZ	smoothingZtime_bucket_rangerrrr XszRateClocker.__init__rcCs�|j�||jj�}tj||j�|j}|j|7_||jkr||jt||j�}||j	|j
d|j	|_
d|_||_|j
SQRXdS)Nrr)rrrr.r/r2r3r0�floatr-r,)rZamount�trZcurrent_raterrrr#bs

zRateClocker.recordcCs|jS)N)r,)rrrrr(sszRateClocker.measured_rateN)r)
r)r*r+�__doc__Z_DEFAULT_SMOOTHINGr1r r#�propertyr(rrrrr
Qs	
r
)r.ZloggingrZbotocore.retriesrrrZ	getLoggerr)r%r�objectrr
rrrr�<module>s
+