+
    [mÀhó<  ã                   ó¸   € ^ RI t ^ RIt ! R R]4      t ! R R4      t ! R R4      t ! R R	4      t ! R
 R4      t ! R R4      t ! R R4      t	 ! R R4      t
R# )é    Nc                   ó2   a a€ ] tR t^t oV 3R ltRtVtV ;t# )ÚRequestExceededExceptionc                óN   <€ Wn         W n        RV RV 2p\        SV `  V4       R# )a`  Error when requested amount exceeds what is allowed

The request that raised this error should be retried after waiting
the time specified by ``retry_time``.

:type requested_amt: int
:param requested_amt: The originally requested byte amount

:type retry_time: float
:param retry_time: The length in time to wait to retry for the
    requested amount
zRequest amount z) exceeded the amount available. Retry in N)Úrequested_amtÚ
retry_timeÚsuperÚ__init__)Úselfr   r   ÚmsgÚ	__class__s   &&& €Ú6/usr/lib/python3/dist-packages/s3transfer/bandwidth.pyr	   Ú!RequestExceededException.__init__   s2   ø€ ð +ÔØ$ŒØ ˜Ð.WÐXbÐWcÐdˆÜ‰Ñ˜Öó    ©r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r	   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r   Ú__classdict__s   @@r   r   r      s   ù‡ € ÷õ r   r   c                   ó   € ] tR t^%tRtRtR# )ÚRequestTokenzDA token to pass as an identifier when consuming from the LeakyBucket© N)r   r   r   r   Ú__doc__r   r   r   r   r   r   %   s   † ÙNãr   r   c                   ó,   a € ] tR t^+t o R tR tRtV tR# )Ú	TimeUtilsc                ó,   € \         P                   ! 4       # )zOGet the current time back

:rtype: float
:returns: The current time in seconds
)Útime©r
   s   &r   r    ÚTimeUtils.time,   s   € ô �yŠy‹{Ðr   c                ó.   € \         P                  ! V4      # )z_Sleep for a designated time

:type value: float
:param value: The time to sleep for in seconds
)r    Úsleep)r
   Úvalues   &&r   r$   ÚTimeUtils.sleep4   s   € ô �zŠz˜%Ó Ð r   r   N)r   r   r   r   r    r$   r   r   ©r   s   @r   r   r   +   s   ø‡ € ò÷!ð !r   r   c                   ó4   a € ] tR t^=t o RR ltRR ltRtV tR# )ÚBandwidthLimiterNc                óH   € Wn         W n        Vf   \        4       V n        R# R# )zæLimits bandwidth for shared S3 transfers

:type leaky_bucket: LeakyBucket
:param leaky_bucket: The leaky bucket to use limit bandwidth

:type time_utils: TimeUtils
:param time_utils: Time utility to use for interacting with time.
N)Ú_leaky_bucketÚ_time_utilsr   )r
   Úleaky_bucketÚ
time_utilss   &&&r   r	   ÚBandwidthLimiter.__init__>   s%   € ð *ÔØ%ÔØÒÜ(›{ˆDÖñ r   c                óv   € \        WP                  W P                  4      pV'       g   VP                  4        V# )aŽ  Wraps a fileobj in a bandwidth limited stream wrapper

:type fileobj: file-like obj
:param fileobj: The file-like obj to wrap

:type transfer_coordinator: s3transfer.futures.TransferCoordinator
param transfer_coordinator: The coordinator for the general transfer
    that the wrapped stream is a part of

:type enabled: boolean
:param enabled: Whether bandwidth limiting should be enabled to start
)ÚBandwidthLimitedStreamr+   r,   Údisable_bandwidth_limiting)r
   ÚfileobjÚtransfer_coordinatorÚenabledÚstreams   &&&& r   Úget_bandwith_limited_streamÚ,BandwidthLimiter.get_bandwith_limited_streamL   s6   € ô (Ø×'Ñ'Ð)=×?OÑ?Oó
ˆ÷ Ø×-Ñ-Ô/Øˆr   )r+   r,   ©N)T)r   r   r   r   r	   r7   r   r   r'   s   @r   r)   r)   =   s   ø‡ € ô+÷ò r   r)   c                   óp   a € ] tR t^ct o RR ltR tR tR tR tR t	R t
RR	 ltR
 tR tR tR tRtV tR# )r1   Nc                ó¢   € Wn         W n        W0n        W@n        Vf   \	        4       V n        RV n        \        4       V n        ^ V n        WPn	        R# )a  Limits bandwidth for reads on a wrapped stream

:type fileobj: file-like object
:param fileobj: The file like object to wrap

:type leaky_bucket: LeakyBucket
:param leaky_bucket: The leaky bucket to use to throttle reads on
    the stream

:type transfer_coordinator: s3transfer.futures.TransferCoordinator
param transfer_coordinator: The coordinator for the general transfer
    that the wrapped stream is a part of

:type time_utils: TimeUtils
:param time_utils: The time utility to use for interacting with time
NT)
Ú_fileobjr+   Ú_transfer_coordinatorr,   r   Ú_bandwidth_limiting_enabledr   Ú_request_tokenÚ_bytes_seenÚ_bytes_threshold)r
   r3   r-   r4   r.   Úbytes_thresholds   &&&&&&r   r	   ÚBandwidthLimitedStream.__init__d   sK   € ð0  ŒØ)ÔØ%9Ô"Ø%ÔØÒÜ(›{ˆDÔØ+/ˆÔ(Ü*›nˆÔØˆÔØ /Ör   c                ó   € RV n         R# )z0Enable bandwidth limiting on reads to the streamTN©r>   r!   s   &r   Úenable_bandwidth_limitingÚ0BandwidthLimitedStream.enable_bandwidth_limiting‡   s
   € à+/ˆÖ(r   c                ó   € RV n         R# )z1Disable bandwidth limiting on reads to the streamFNrE   r!   s   &r   r2   Ú1BandwidthLimitedStream.disable_bandwidth_limiting‹   s
   € à+0ˆÖ(r   c                óP  € V P                   '       g   V P                  P                  V4      # V ;P                  V,          un        V P                  V P                  8  d   V P                  P                  V4      # V P                  4        V P                  P                  V4      # )zXRead a specified amount

Reads will only be throttled if bandwidth limiting is enabled.
)r>   r<   Úreadr@   rA   Ú_consume_through_leaky_bucket)r
   Úamounts   &&r   rK   ÚBandwidthLimitedStream.read�   s‚   € ð
 ×/×/Ð/Ø—=‘=×%Ñ% fÓ-Ð-ð 	×Ò˜FÕ"ÕØ×Ñ˜d×3Ñ3Ô3Ø—=‘=×%Ñ% fÓ-Ð-à×*Ñ*Ô,Ø�}‰}×!Ñ! &Ó)Ð)r   c                óV  € V P                   P                  '       g;    V P                  P                  V P                  V P
                  4       ^ V n        R# V P                   P                  h  \         d1   pT P                  P                  TP                  4        Rp?K¢  Rp?ii ; i)r   N)
r=   Ú	exceptionr+   Úconsumer@   r?   r   r,   r$   r   )r
   Úes   & r   rL   Ú4BandwidthLimitedStream._consume_through_leaky_bucket£   sŽ   € ð ×,Ñ,×6×6Ð6ð5Ø×"Ñ"×*Ñ*Ø×$Ñ$ d×&9Ñ&9ôð $%�Ô Ùð ×,Ñ,×6Ñ6Ð6øô ,ô 5Ø× Ñ ×&Ñ& q§|¡|×4Ò4ûð5ús   ž7A- Á-B(Á8%B#Â#B(c                ó&   € V P                  4        R# )z6Signal that data being read is being transferred to S3N)rF   r!   s   &r   Úsignal_transferringÚ*BandwidthLimitedStream.signal_transferringµ   s   € à×&Ñ&Ö(r   c                ó&   € V P                  4        R# )z:Signal that data being read is not being transferred to S3N)r2   r!   s   &r   Úsignal_not_transferringÚ.BandwidthLimitedStream.signal_not_transferring¹   s   € à×'Ñ'Ö)r   c                ó<   € V P                   P                  W4       R # r9   )r<   Úseek)r
   ÚwhereÚwhences   &&&r   r[   ÚBandwidthLimitedStream.seek½   s   € Ø�‰×Ñ˜5Ö)r   c                ó6   € V P                   P                  4       # r9   )r<   Útellr!   s   &r   r`   ÚBandwidthLimitedStream.tellÀ   s   € Ø�}‰}×!Ñ!Ó#Ð#r   c                ó¢   € V P                   '       d#   V P                  '       d   V P                  4        V P                  P	                  4        R # r9   )r>   r@   rL   r<   Úcloser!   s   &r   rc   ÚBandwidthLimitedStream.closeÃ   s7   € Ø×+×+Ð+°×0@×0@Ð0@ð ×.Ñ.Ô0Ø�‰×ÑÖr   c                ó   € V # r9   r   r!   s   &r   Ú	__enter__Ú BandwidthLimitedStream.__enter__Í   s   € Øˆr   c                ó&   € V P                  4        R # r9   )rc   )r
   ÚargsÚkwargss   &*,r   Ú__exit__ÚBandwidthLimitedStream.__exit__Ð   s   € Ø�
‰
Žr   )r>   r@   rA   r<   r+   r?   r,   r=   )Ni   )r   )r   r   r   r   r	   rF   r2   rK   rL   rU   rX   r[   r`   rc   rf   rk   r   r   r'   s   @r   r1   r1   c   sG   ø‡ € ô!0òF0ò1ò*ò(7ò$)ò*ô*ò$òò÷ð r   r1   c                   óH   a € ] tR t^Ôt o R	R ltR tR tR tR tR t	Rt
V tR# )
ÚLeakyBucketNc                óô   € \        V4      V n        W n        Vf   \        4       V n        \        P
                  ! 4       V n        W0n        Vf   \        4       V n        W@n	        Vf   \        4       V n	        R# R# )aá  A leaky bucket abstraction to limit bandwidth consumption

:type rate: int
:type rate: The maximum rate to allow. This rate is in terms of
    bytes per second.

:type time_utils: TimeUtils
:param time_utils: The time utility to use for interacting with time

:type rate_tracker: BandwidthRateTracker
:param rate_tracker: Tracks bandwidth consumption

:type consumption_scheduler: ConsumptionScheduler
:param consumption_scheduler: Schedules consumption retries when
    necessary
N)ÚfloatÚ	_max_rater,   r   Ú	threadingÚLockÚ_lockÚ_rate_trackerÚBandwidthRateTrackerÚ_consumption_schedulerÚConsumptionScheduler)r
   Úmax_rater.   Úrate_trackerÚconsumption_schedulers   &&&&&r   r	   ÚLeakyBucket.__init__Õ   sf   € ô. ˜x›ˆŒØ%ÔØÒÜ(›{ˆDÔÜ—^’^Ó%ˆŒ
Ø)ÔØÒÜ!5Ó!7ˆDÔØ&;Ô#Ø Ò(Ü*>Ó*@ˆDÖ'ñ )r   c                ó¢  € V P                   ;_uu_ 4        V P                  P                  4       pV P                  P	                  V4      '       d   V P                  WV4      uuRRR4       # V P                  W4      '       d   V P                  WV4       MV P                  W4      uuRRR4       #  RRR4       R#   + '       g   i     R# ; i)a  Consume an a requested amount

:type amt: int
:param amt: The amount of bytes to request to consume

:type request_token: RequestToken
:param request_token: The token associated to the consumption
    request that is used to identify the request. So if a
    RequestExceededException is raised the token should be used
    in subsequent retry consume() request.

:raises RequestExceededException: If the consumption amount would
    exceed the maximum allocated bandwidth

:rtype: int
:returns: The amount consumed
N)	rt   r,   r    rw   Úis_scheduledÚ,_release_requested_amt_for_scheduled_requestÚ_projected_to_exceed_max_rateÚ!_raise_request_exceeded_exceptionÚ_release_requested_amt©r
   ÚamtÚrequest_tokenÚtime_nows   &&& r   rQ   ÚLeakyBucket.consumeø   s    € ð$ �Z�Z‹ZØ×'Ñ'×,Ñ,Ó.ˆHØ×*Ñ*×7Ñ7¸×FÒFØ×HÑHØ¨ó÷ ŠZð ×3Ñ3°C×BÒBØ×6Ñ6Ø¨õð ×2Ñ2°3ÓA÷ ŠZð÷ �Z�ZŠZús   •AB=Á-:B=Â=C	c                óT   € V P                   P                  W4      pW0P                  8„  # r9   )ru   Úget_projected_raterq   )r
   r„   r†   Úprojected_rates   &&& r   r€   Ú)LeakyBucket._projected_to_exceed_max_rate  s%   € Ø×+Ñ+×>Ñ>¸sÓMˆØ§¡Ñ.Ð.r   c                óZ   € V P                   P                  V4       V P                  W4      # r9   )rw   Úprocess_scheduled_consumptionr‚   rƒ   s   &&&&r   r   Ú8LeakyBucket._release_requested_amt_for_scheduled_request  s.   € ð 	×#Ñ#×AÑAØô	
ð ×*Ñ*¨3Ó9Ð9r   c                óŠ   € V\        V P                  4      ,          pV P                  P                  WV4      p\	        WR 7      h)r   )rp   rq   rw   Úschedule_consumptionr   )r
   r„   r…   r†   Úallocated_timer   s   &&&&  r   r�   Ú-LeakyBucket._raise_request_exceeded_exception#  sB   € Øœu T§^¡^Ó4Õ4ˆØ×0Ñ0×EÑEØ ó
ˆ
ô 'Øô
ð 	
r   c                ó<   € V P                   P                  W4       V# r9   )ru   Úrecord_consumption_rate)r
   r„   r†   s   &&&r   r‚   Ú"LeakyBucket._release_requested_amt,  s   € Ø×Ñ×2Ñ2°3ÔAØˆ
r   )rw   rt   rq   ru   r,   )NNN)r   r   r   r   r	   rQ   r€   r   r�   r‚   r   r   r'   s   @r   rn   rn   Ô   s+   ø‡ € ô!AòFBò>/ò:ò
÷ð r   rn   c                   ó8   a € ] tR tRt o R tR tR tR tRtV t	R# )rx   i1  c                ó"   € / V n         ^ V n        R# )z*Schedules when to consume a desired amountN©Ú _tokens_to_scheduled_consumptionÚ_total_waitr!   s   &r   r	   ÚConsumptionScheduler.__init__2  s   € à02ˆÔ-ØˆÖr   c                ó   € WP                   9   # )z¹Indicates if a consumption request has been scheduled

:type token: RequestToken
:param token: The token associated to the consumption
    request that is used to identify the request.
)r™   )r
   Útokens   &&r   r~   Ú!ConsumptionScheduler.is_scheduled7  s   € ð ×=Ñ=Ñ=Ð=r   c                ó†   € V ;P                   V,          un         RV P                   RV/V P                  V&   V P                   # )aL  Schedules a wait time to be able to consume an amount

:type amt: int
:param amt: The amount of bytes scheduled to be consumed

:type token: RequestToken
:param token: The token associated to the consumption
    request that is used to identify the request.

:type time_to_consume: float
:param time_to_consume: The desired time it should take for that
    specific request amount to be consumed in regardless of previously
    scheduled consumption requests

:rtype: float
:returns: The amount of time to wait for the specific request before
    actually consuming the specified amount.
Úwait_durationÚtime_to_consume)rš   r™   )r
   r„   r�   r¡   s   &&&&r   r�   Ú)ConsumptionScheduler.schedule_consumption@  sE   € ð& 	×Ò˜OÕ+Õà˜T×-Ñ-Ø˜ð8
ˆ×-Ñ-¨eÑ4ð ×ÑÐr   c                óŽ   € V P                   P                  V4      p\        V P                  VR,          ,
          ^ 4      V n        R# )zÀProcesses a scheduled consumption request that has completed

:type token: RequestToken
:param token: The token associated to the consumption
    request that is used to identify the request.
r¡   N)r™   ÚpopÚmaxrš   )r
   r�   Úscheduled_retrys   && r   r�   Ú2ConsumptionScheduler.process_scheduled_consumptionZ  s=   € ð ×?Ñ?×CÑCÀEÓJˆÜØ×Ñ˜Ð/@ÕAÕAÀ1ó
ˆÖr   r˜   N)
r   r   r   r   r	   r~   r�   r�   r   r   r'   s   @r   rx   rx   1  s   ø‡ € òò
>ò ÷4

ð 

r   rx   c                   óR   a € ] tR tRt o R
R lt]R 4       tR tR tR t	R t
RtV tR	# )rv   ig  c                ó.   € Wn         RV n        RV n        R# )aZ  Tracks the rate of bandwidth consumption

:type a: float
:param a: The constant to use in calculating the exponentional moving
    average of the bandwidth rate. Specifically it is used in the
    following calculation:

    current_rate = alpha * new_rate + (1 - alpha) * current_rate

    This value of this constant should be between 0 and 1.
N)Ú_alphaÚ
_last_timeÚ_current_rate)r
   Úalphas   &&r   r	   ÚBandwidthRateTracker.__init__h  s   € ð ŒØˆŒØ!ˆÖr   c                ó:   € V P                   f   R# V P                  # )zUThe current transfer rate

:rtype: float
:returns: The current tracked transfer rate
ç        )r«   r¬   r!   s   &r   Úcurrent_rateÚ!BandwidthRateTracker.current_ratex  s   € ð �?‰?Ò"ÙØ×!Ñ!Ð!r   c                óD   € V P                   f   R# V P                  W4      # )a"  Get the projected rate using a provided amount and time

:type amt: int
:param amt: The proposed amount to consume

:type time_at_consumption: float
:param time_at_consumption: The proposed time to consume at

:rtype: float
:returns: The consumption rate if that amt and time were consumed
r°   )r«   Ú*_calculate_exponential_moving_average_rate©r
   r„   Útime_at_consumptions   &&&r   r‰   Ú'BandwidthRateTracker.get_projected_rateƒ  s'   € ð �?‰?Ò"ÙØ×>Ñ>Øó
ð 	
r   c                óx   € V P                   f   W n         RV n        R# V P                  W4      V n        W n         R# )zÝRecord the consumption rate based off amount and time point

:type amt: int
:param amt: The amount that got consumed

:type time_at_consumption: float
:param time_at_consumption: The time at which the amount was consumed
Nr°   )r«   r¬   r´   rµ   s   &&&r   r”   Ú,BandwidthRateTracker.record_consumption_rate•  s;   € ð �?‰?Ò"Ø1ŒOØ!$ˆDÔÙØ!×LÑLØó
ˆÔð .Žr   c                óZ   € W P                   ,
          pV^ 8:  d   \        R4      # W,          # )r   Úinf)r«   rp   )r
   r„   r¶   Ú
time_deltas   &&& r   Ú_calculate_rateÚ$BandwidthRateTracker._calculate_rate§  s*   € Ø(¯?©?Õ:ˆ
Ø˜Œ?ô
 ˜“<ÐØÕ!Ð!r   c                óœ   € V P                  W4      pV P                  V,          ^V P                  ,
          V P                  ,          ,           # )é   )r½   rª   r¬   )r
   r„   r¶   Únew_rates   &&& r   r´   Ú?BandwidthRateTracker._calculate_exponential_moving_average_rate±  s;   € ð ×'Ñ'¨ÓAˆØ�{‰{˜XÕ%¨¨T¯[©[­¸D×<NÑ<NÕ(NÕNÐNr   )rª   r¬   r«   N)gš™™™™™é?)r   r   r   r   r	   Úpropertyr±   r‰   r”   r½   r´   r   r   r'   s   @r   rv   rv   g  s9   ø‡ € ô"ð  ñ"ó ð"ò
ò$.ò$"÷Oð Or   rv   )rr   r    Ú	Exceptionr   r   r   r)   r1   rn   rx   rv   r   r   r   Ú<module>rÅ      sk   ðó Û ô˜yô ÷(	ñ 	÷!ñ !÷$#ñ #÷Lnñ n÷bZñ Z÷z3
ñ 3
÷lNOó NOr   