https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/s3transfer/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/s3transfer/__pycache__/bandwidth.cpython-310.pyc
o

�y�`-=�@s�ddlZddlZGdd�de�ZGdd�de�ZGdd�de�ZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�Z	Gdd�de�Z
Gdd�de�ZdS)�NcseZdZ�fdd�Z�ZS)�RequestExceededExceptioncs,||_||_d||f}tt|��|�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)�
requested_amt�
retry_time�superr�__init__)�selfrr�msg��	__class__��6/usr/lib/python3/dist-packages/s3transfer/bandwidth.pyrs
��z!RequestExceededException.__init__)�__name__�
__module__�__qualname__r�
__classcell__rrr	rrsrc@seZdZdZdS)�RequestTokenzDA token to pass as an identifier when consuming from the LeakyBucketN)r
rr�__doc__rrrrr(src@seZdZdd�Zdd�ZdS)�	TimeUtilscCst��S)zgGet the current time back

        :rtype: float
        :returns: The current time in seconds
        )�time�rrrrr.szTimeUtils.timecCs
t�|�S)zwSleep for a designated time

        :type value: float
        :param value: The time to sleep for in seconds
        )r�sleep)r�valuerrrr6s
zTimeUtils.sleepN)r
rrrrrrrrr-src@s"eZdZddd�Z	ddd�ZdS)	�BandwidthLimiterNcCs$||_||_|durt�|_dSdS)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)�
_leaky_bucket�_time_utilsr)r�leaky_bucket�
time_utilsrrrr@s
	�zBandwidthLimiter.__init__TcCs"t||j||j�}|s|��|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
        )�BandwidthLimitedStreamrr�disable_bandwidth_limiting)r�fileobj�transfer_coordinator�enabled�streamrrr�get_bandwith_limited_streamNs�z,BandwidthLimiter.get_bandwith_limited_stream�N)T)r
rrrr#rrrrr?s
�rc@sreZdZ	ddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	ddd�Z
dd�Zdd�Zdd�Z
dd�ZdS)rN�cCsF||_||_||_||_|durt�|_d|_t�|_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)
�_fileobjr�_transfer_coordinatorrr�_bandwidth_limiting_enabledr�_request_token�_bytes_seen�_bytes_threshold)rrrr r�bytes_thresholdrrrres
zBandwidthLimitedStream.__init__cC�
d|_dS)z0Enable bandwidth limiting on reads to the streamTN�r(rrrr�enable_bandwidth_limiting��
z0BandwidthLimitedStream.enable_bandwidth_limitingcCr-)z1Disable bandwidth limiting on reads to the streamFNr.rrrrr�r0z1BandwidthLimitedStream.disable_bandwidth_limitingcCsL|js	|j�|�S|j|7_|j|jkr|j�|�S|��|j�|�S)zhRead a specified amount

        Reads will only be throttled if bandwidth limiting is enabled.
        )r(r&�readr*r+�_consume_through_leaky_bucket)r�amountrrrr1�szBandwidthLimitedStream.readc
Csj|jjs1z|j�|j|j�d|_WdSty,}z
|j�|j	�WYd}~nd}~ww|jjr|jj�)Nr)
r'�	exceptionr�consumer*r)rrrr)r�errrr2�s����	z4BandwidthLimitedStream._consume_through_leaky_bucketcC�|��dS)z6Signal that data being read is being transferred to S3N)r/rrrr�signal_transferring��z*BandwidthLimitedStream.signal_transferringcCr7)z:Signal that data being read is not being transferred to S3N)rrrrr�signal_not_transferring�r9z.BandwidthLimitedStream.signal_not_transferringrcCs|j�||�dSr$)r&�seek)r�where�whencerrrr;�szBandwidthLimitedStream.seekcCs
|j��Sr$)r&�tellrrrrr>�s
zBandwidthLimitedStream.tellcCs"|jr
|jr
|��|j��dSr$)r(r*r2r&�closerrrrr?�szBandwidthLimitedStream.closecCs|Sr$rrrrr�	__enter__�sz BandwidthLimitedStream.__enter__cOs|��dSr$)r?)r�args�kwargsrrr�__exit__�szBandwidthLimitedStream.__exit__)Nr%)r)r
rrrr/rr1r2r8r:r;r>r?r@rCrrrrrds
�

rc@sBeZdZ		ddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)�LeakyBucketNcCs^t|�|_||_|durt�|_t��|_||_|dur t�|_||_	|dur-t
�|_	dSdS)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)�float�	_max_raterr�	threading�Lock�_lock�
_rate_tracker�BandwidthRateTracker�_consumption_scheduler�ConsumptionScheduler)r�max_rater�rate_tracker�consumption_schedulerrrrr�s

�zLeakyBucket.__init__cCs�|j�=|j��}|j�|�r|�|||�Wd�S|�||�r+|�|||�n
|�||�Wd�SWd�dS1sCwYdS)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)	rIrrrL�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_nowrrrr5�s
���
�"�zLeakyBucket.consumecCs|j�||�}||jkSr$)rJ�get_projected_raterF)rrWrY�projected_raterrrrS
s
z)LeakyBucket._projected_to_exceed_max_ratecCs|j�|�|�||�Sr$)rL�process_scheduled_consumptionrUrVrrrrRs�z8LeakyBucket._release_requested_amt_for_scheduled_requestcCs*|t|j�}|j�|||�}t||d��)N)rr)rErFrL�schedule_consumptionr)rrWrXrY�allocated_timerrrrrTs��z-LeakyBucket._raise_request_exceeded_exceptioncCs|j�||�|Sr$)rJ�record_consumption_rate)rrWrYrrrrUsz"LeakyBucket._release_requested_amt)NNN)	r
rrrr5rSrRrTrUrrrrrD�s
�rDc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rMcCsi|_d|_dS)z*Schedules when to consume a desired amountrN)� _tokens_to_scheduled_consumption�_total_waitrrrrr!s
zConsumptionScheduler.__init__cCs
||jvS)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�tokenrrrrQ&s
z!ConsumptionScheduler.is_scheduledcCs&|j|7_|j|d�|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.
        )�
wait_duration�time_to_consume)rar`)rrWrbrdrrrr]/s
�z)ConsumptionScheduler.schedule_consumptioncCs&|j�|�}t|j|dd�|_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.
        rdrN)r`�pop�maxra)rrb�scheduled_retryrrrr\Is
�z2ConsumptionScheduler.process_scheduled_consumptionN)r
rrrrQr]r\rrrrrM s
	rMc@sBeZdZddd�Zedd��Zdd�Zdd	�Zd
d�Zdd
�Z	dS)rK皙�����?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)�_alpha�
_last_time�
_current_rate)r�alpharrrrVs
zBandwidthRateTracker.__init__cCs|jdurdS|jS)zmThe current transfer rate

        :rtype: float
        :returns: The current tracked transfer rate
        N�)rjrkrrrr�current_ratefs
z!BandwidthRateTracker.current_ratecCs|jdurdS|�||�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
        Nrm)rj�*_calculate_exponential_moving_average_rate�rrW�time_at_consumptionrrrrZqs

�z'BandwidthRateTracker.get_projected_ratecCs2|jdur
||_d|_dS|�||�|_||_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
        Nrm)rjrkrorprrrr_�s
	�
z,BandwidthRateTracker.record_consumption_ratecCs"||j}|dkr
td�S||S)Nr�inf)rjrE)rrWrq�
time_deltarrr�_calculate_rate�s
z$BandwidthRateTracker._calculate_ratecCs&|�||�}|j|d|j|jS)N�)rtrirk)rrWrq�new_raterrrro�sz?BandwidthRateTracker._calculate_exponential_moving_average_rateN)rh)
r
rrr�propertyrnrZr_rtrorrrrrKUs



rK)rrG�	Exceptionr�objectrrrrrDrMrKrrrr�<module>s%jR5

https://t.me/RX1948 - 2025