Files
old-parkingkoncept/parkingkonceptvenv/lib/python3.7/site-packages/s3transfer/__pycache__/bandwidth.cpython-37.pyc

281 lines
14 KiB
Plaintext
Raw Normal View History

2019-11-17 12:44:16 +01:00
B
<00>[<5B>]=<00>@s<>ddlZddlZGdd<03>de<02>ZGdd<05>de<04>ZGdd<07>de<04>ZGdd <09>d e<04>ZGd
d <0B>d e<04>ZGd d <0A>d e<04>Z Gdd<0F>de<04>Z
Gdd<11>de<04>Z dS)<12>NcseZdZ<02>fdd<02>Z<03>ZS)<03>RequestExceededExceptioncs,||_||_d||f}tt|<00><02>|<03>dS)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 %s exceeded the amount available. Retry in %sN)<05> requested_amt<6D>
retry_time<EFBFBD>superr<00>__init__)<04>selfrr<00>msg)<01> __class__<5F><00></tmp/pip-install-u_6_z2pz/s3transfer/s3transfer/bandwidth.pyrs

z!RequestExceededException.__init__)<05>__name__<5F>
__module__<EFBFBD> __qualname__r<00> __classcell__r
r
)r r rsrc@seZdZdZdS)<03> RequestTokenzDA token to pass as an identifier when consuming from the LeakyBucketN)r r r<00>__doc__r
r
r
r r(src@seZdZdd<02>Zdd<04>ZdS)<06> TimeUtilscCst<00><00>S)zgGet the current time back
:rtype: float
:returns: The current time in seconds
)<01>time)rr
r
r r.szTimeUtils.timecCs
t<00>|<01>S)zwSleep for a designated time
:type value: float
:param value: The time to sleep for in seconds
)r<00>sleep)r<00>valuer
r
r r6szTimeUtils.sleepN)r r rrrr
r
r
r r-src@s eZdZddd<03>Zddd<06>ZdS) <09>BandwidthLimiterNcCs ||_||_|dkrt<02>|_dS)aLimits 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)<03> _leaky_bucket<65> _time_utilsr)r<00> leaky_bucket<65>
time_utilsr
r
r r@s zBandwidthLimiter.__init__TcCs"t||j||j<02>}|s|<04><03>|S)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
)<04>BandwidthLimitedStreamrr<00>disable_bandwidth_limiting)r<00>fileobj<62>transfer_coordinatorZenabled<65>streamr
r
r <00>get_bandwith_limited_streamNs z,BandwidthLimiter.get_bandwith_limited_stream)N)T)r r rrr r
r
r
r r?s
rc@sneZdZddd<04>Zdd<06>Zdd<08>Zd d
<EFBFBD>Zd d <0C>Zd d<0E>Zdd<10>Z dd<12>Z
dd<14>Z dd<16>Z dd<18>Z dd<1A>ZdS)rN<>cCsF||_||_||_||_|dkr(t<04>|_d|_t<06>|_d|_||_ dS)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
NTr)
<EFBFBD>_fileobjr<00>_transfer_coordinatorrr<00>_bandwidth_limiting_enabledr<00>_request_token<65> _bytes_seen<65>_bytes_threshold)rrrrrZbytes_thresholdr
r
r reszBandwidthLimitedStream.__init__cCs
d|_dS)z0Enable bandwidth limiting on reads to the streamTN)r$)rr
r
r <00>enable_bandwidth_limiting<6E>sz0BandwidthLimitedStream.enable_bandwidth_limitingcCs
d|_dS)z1Disable bandwidth limiting on reads to the streamFN)r$)rr
r
r r<00>sz1BandwidthLimitedStream.disable_bandwidth_limitingcCsL|js|j<01>|<01>S|j|7_|j|jkr8|j<01>|<01>S|<00><05>|j<01>|<01>S)zhRead a specified amount
Reads will only be throttled if bandwidth limiting is enabled.
)r$r"<00>readr&r'<00>_consume_through_leaky_bucket)r<00>amountr
r
r r)<00>s   zBandwidthLimitedStream.readc
Cshxb|jjsZy|j<02>|j|j<05>d|_dStk
rV}z|j<07>|j <09>Wdd}~XYqXqW|jj<01>dS)Nr)
r#<00> exceptionr<00>consumer&r%rrrr)r<00>er
r
r r*<00>s
 $z4BandwidthLimitedStream._consume_through_leaky_bucketcCs |<00><00>dS)z6Signal that data being read is being transferred to S3N)r()rr
r
r <00>signal_transferring<6E>sz*BandwidthLimitedStream.signal_transferringcCs |<00><00>dS)z:Signal that data being read is not being transferred to S3N)r)rr
r
r <00>signal_not_transferring<6E>sz.BandwidthLimitedStream.signal_not_transferringcCs|j<00>|<01>dS)N)r"<00>seek)r<00>wherer
r
r r1<00>szBandwidthLimitedStream.seekcCs
|j<00><01>S)N)r"<00>tell)rr
r
r r3<00>szBandwidthLimitedStream.tellcCs"|jr|jr|<00><02>|j<03><04>dS)N)r$r&r*r"<00>close)rr
r
r r4<00>s zBandwidthLimitedStream.closecCs|S)Nr
)rr
r
r <00> __enter__<5F>sz BandwidthLimitedStream.__enter__cOs |<00><00>dS)N)r4)r<00>args<67>kwargsr
r
r <00>__exit__<5F>szBandwidthLimitedStream.__exit__)Nr!)r r rrr(rr)r*r/r0r1r3r4r5r8r
r
r
r rds

rc@s>eZdZddd<03>Zdd<05>Zdd<07>Zdd <09>Zd
d <0B>Zd d <0A>ZdS)<0F> LeakyBucketNcCsZt|<01>|_||_|dkr t<03>|_t<04><05>|_||_|dkr@t<08>|_||_ |dkrVt
<EFBFBD>|_ dS)a9A 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) <0B>float<61> _max_raterr<00> threading<6E>Lock<63>_lock<63> _rate_tracker<65>BandwidthRateTracker<65>_consumption_scheduler<65>ConsumptionScheduler)rZmax_raterZ rate_trackerZconsumption_schedulerr
r
r r<00>s

zLeakyBucket.__init__c Csb|j<00>R|j<01><02>}|j<03>|<02>r,|<00>|||<03>S|<00>||<03>rH|<00>|||<03>n |<00>||<03>SWdQRXdS)acConsume 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) r>rrrA<00> is_scheduled<65>,_release_requested_amt_for_scheduled_request<73>_projected_to_exceed_max_rate<74>!_raise_request_exceeded_exception<6F>_release_requested_amt)r<00>amt<6D> request_token<65>time_nowr
r
r r-<00>s
 
  zLeakyBucket.consumecCs|j<00>||<02>}||jkS)N)r?<00>get_projected_rater;)rrHrJZprojected_rater
r
r rE
sz)LeakyBucket._projected_to_exceed_max_ratecCs|j<00>|<02>|<00>||<03>S)N)rA<00>process_scheduled_consumptionrG)rrHrIrJr
r
r rDsz8LeakyBucket._release_requested_amt_for_scheduled_requestcCs.|t|j<01>}|j<02>|||<04>}t||d<01><02>dS)N)rr)r:r;rA<00>schedule_consumptionr)rrHrIrJZallocated_timerr
r
r rFs

z-LeakyBucket._raise_request_exceeded_exceptioncCs|j<00>||<02>|S)N)r?<00>record_consumption_rate)rrHrJr
r
r rGsz"LeakyBucket._release_requested_amt)NNN) r r rrr-rErDrFrGr
r
r
r r9<00>s
r9c@s,eZdZdd<02>Zdd<04>Zdd<06>Zdd<08>Zd S)
rBcCsi|_d|_dS)z*Schedules when to consume a desired amountrN)<02> _tokens_to_scheduled_consumption<6F> _total_wait)rr
r
r r!szConsumptionScheduler.__init__cCs
||jkS)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.
)rO)r<00>tokenr
r
r rC&sz!ConsumptionScheduler.is_scheduledcCs&|j|7_|j|d<01>|j|<|jS)a<>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.
)Z wait_duration<6F>time_to_consume)rPrO)rrHrQrRr
r
r rM/sz)ConsumptionScheduler.schedule_consumptioncCs&|j<00>|<01>}t|j|dd<02>|_dS)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.
rRrN)rO<00>pop<6F>maxrP)rrQZscheduled_retryr
r
r rLIs z2ConsumptionScheduler.process_scheduled_consumptionN)r r rrrCrMrLr
r
r
r rB s rBc@sBeZdZddd<03>Zedd<05><00>Zdd<07>Zdd <09>Zd
d <0B>Zd d <0A>Z dS)r@<><E79A99><EFBFBD><EFBFBD><EFBFBD>?cCs||_d|_d|_dS)a<>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)<03>_alpha<68>
_last_time<EFBFBD> _current_rate)r<00>alphar
r
r rVs zBandwidthRateTracker.__init__cCs|jdkrdS|jS)zmThe current transfer rate
:rtype: float
:returns: The current tracked transfer rate
Ng)rWrX)rr
r
r <00> current_ratefs
z!BandwidthRateTracker.current_ratecCs|jdkrdS|<00>||<02>S)aZGet 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
Ng)rW<00>*_calculate_exponential_moving_average_rate)rrH<00>time_at_consumptionr
r
r rKqs
z'BandwidthRateTracker.get_projected_ratecCs2|jdkr||_d|_dS|<00>||<02>|_||_dS)aRecord 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
Ng)rWrXr[)rrHr\r
r
r rN<00>s

z,BandwidthRateTracker.record_consumption_ratecCs"||j}|dkrtd<02>S||S)Nr<00>inf)rWr:)rrHr\Z
time_deltar
r
r <00>_calculate_rate<74>s
z$BandwidthRateTracker._calculate_ratecCs&|<00>||<02>}|j|d|j|jS)N<>)r^rVrX)rrHr\Znew_rater
r
r r[<00>s z?BandwidthRateTracker._calculate_exponential_moving_average_rateN)rU)
r r rr<00>propertyrZrKrNr^r[r
r
r
r r@Us 
 
r@) rr<<00> Exceptionr<00>objectrrrrr9rBr@r
r
r
r <00><module> s%jR5