
    'wf                     ~    d Z ddlZddlZddlmZmZ ddlmZ ddlm	Z	  ej                  e      Zd Z G d d	      Zy)
zRAn async reimplementation of the blocking elements from botocore.retries.adaptive.    N)standard
throttling)RateClocker   )bucketc                    t        j                         }t        j                  d|j	                               }t        j
                  d|      }t        |      }t        j                  t        j                               }t        |||||      }| j                  j                  j                  d|j                         | j                  j                  j                  d|j                         |S )	Nr   )starting_max_rate
start_timer   )max_rateclock)retry_event_adapter)rate_adjustorrate_clockertoken_bucketthrottling_detectorr   zbefore-sendzneeds-retry)r   Clockr   CubicCalculatorcurrent_timeAsyncTokenBucketr   r   ThrottlingErrorDetectorRetryEventAdapterAsyncClientRateLimitermetaeventsregisteron_sending_requeston_receiving_response)clientr   r   r   r   r   limiters          p/home/panchajanya/Development/work/volatility3/venv/lib/python3.12/site-packages/aiobotocore/retries/adaptive.pyregister_retry_handlerr!      s    LLNE..(:(:(<M **AUCLu%L"::$668 %#!!/G KK"" KK%% N    c                   &    e Zd ZdZdZd Zd Zd Zy)r   z/An async reimplementation of ClientRateLimiter.g       @c                     || _         || _        || _        || _        || _        d| _        t        j                         | _        y )NF)	_rate_adjustor_rate_clocker_token_bucket_throttling_detector_clock_enabledasyncioLock_lock)selfr   r   r   r   r   s         r    __init__zAsyncClientRateLimiter.__init__8   s?     ,))$7!\\^
r"   c                 n   K   | j                   r#| j                  j                          d {    y y 7 w)N)r*   r'   acquire)r.   requestkwargss      r    r   z)AsyncClientRateLimiter.on_sending_requestH   s-     ==$$,,... .s   *535c                   K   | j                   j                         }| j                  j                         }| j                  4 d {     | j
                  j                  di |s| j                  j                  |      }n~| j                  s|}n t        || j                  j                        }| j                  j                  ||      }t        j                  d||| j                  j                          d| _	        | j                  j#                  t        || j$                  |z               d {    d d d       d {    y 7 7 7 
# 1 d {  7  sw Y   y xY ww)NzfThrottling response received, new send rate: %s measured rate: %s, token bucket capacity available: %sT )r&   recordr)   r   r-   r(   is_throttling_errorr%   success_receivedr*   minr'   r   error_receivedloggerdebugavailable_capacityset_max_rate_MAX_RATE_ADJUST_SCALE)r.   r3   measured_rate	timestampnew_raterate_to_uses         r    r   z,AsyncClientRateLimiter.on_receiving_responseM   sA    **113KK,,.	:: 	 	@4,,@@J6J..??	J}}"/K"%%t'9'9'B'B#K  ..== $ !&&99 !%$$11Hd99MIJ  -	 	 	,-	 	 	 	s[   AE)EE)C,E7E8E<E)EE)EE)E&EE&"E)N)__name__
__module____qualname____doc__r?   r/   r   r   r5   r"   r    r   r   -   s    9 !$ /
r"   r   )rG   r+   loggingbotocore.retriesr   r   botocore.retries.adaptiver    r   	getLoggerrD   r;   r!   r   r5   r"   r    <module>rM      s:    X   1
 2 			8	$8; ;r"   