HEX
Server: LiteSpeed
System: Linux br-asc-web1845.main-hosting.eu 5.14.0-611.42.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Mar 24 05:30:20 EDT 2026 x86_64
User: u790421558 (790421558)
PHP: 8.2.30
Disabled: system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/alt/python311/lib/python3.11/site-packages/s3transfer/__pycache__/bandwidth.cpython-311.pyc
�

`�Zg�<����ddlZddlZGd�de��ZGd�d��ZGd�d��ZGd�d	��ZGd
�d��ZGd�d
��ZGd�d��Z	Gd�d��Z
dS)�Nc���eZdZ�fd�Z�xZS)�RequestExceededExceptionc�v��||_||_d|�d|��}t���|��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
        zRequest amount z) exceeded the amount available. Retry in N)�
requested_amt�
retry_time�super�__init__)�selfrr�msg�	__class__s    ��G/opt/alt/python311/lib/python3.11/site-packages/s3transfer/bandwidth.pyr	z!RequestExceededException.__init__sH���+���$���d�
�d�d�Xb�d�d��
�����������)�__name__�
__module__�__qualname__r	�
__classcell__)rs@r
rrs8���������������rrc��eZdZdZdS)�RequestTokenzDA token to pass as an identifier when consuming from the LeakyBucketN)rrr�__doc__�rr
rr%s������N�N��Drrc��eZdZd�Zd�ZdS)�	TimeUtilsc�(�tj��S)zgGet the current time back

        :rtype: float
        :returns: The current time in seconds
        )�time�r
s r
rzTimeUtils.time,s���y�{�{�rc�*�tj|��S)zwSleep for a designated time

        :type value: float
        :param value: The time to sleep for in seconds
        )r�sleep)r
�values  r
rzTimeUtils.sleep4s���z�%� � � rN)rrrrrrrr
rr+s2���������!�!�!�!�!rrc� �eZdZdd�Z	dd�ZdS)�BandwidthLimiterNc�P�||_||_|�t��|_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_utilss   r
r	zBandwidthLimiter.__init__>s4��*���%�����(�{�{�D�����rTc�j�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
        )�BandwidthLimitedStreamr"r#�disable_bandwidth_limiting)r
�fileobj�transfer_coordinator�enabled�streams     r
�get_bandwith_limited_streamz,BandwidthLimiter.get_bandwith_limited_streamLsD��(��T�'�)=�t�?O�
�
���	0��-�-�/�/�/��
r�N)T)rrrr	r-rrr
r r =sA������+�+�+�+�6:������rr c�^�eZdZ		dd�Zd�Zd�Zd�Zd�Zd�Zd	�Z	dd�Z
d�Zd
�Zd�Z
d�ZdS)r'N�c��||_||_||_||_|�t	��|_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_coordinatorr#r�_bandwidth_limiting_enabledr�_request_token�_bytes_seen�_bytes_threshold)r
r)r$r*r%�bytes_thresholds      r
r	zBandwidthLimitedStream.__init__ds_��0 ��
�)���%9��"�%�����(�{�{�D��+/��(�*�n�n������ /����rc��d|_dS)z0Enable bandwidth limiting on reads to the streamTN�r4rs r
�enable_bandwidth_limitingz0BandwidthLimitedStream.enable_bandwidth_limiting�s��+/��(�(�(rc��d|_dS)z1Disable bandwidth limiting on reads to the streamFNr:rs r
r(z1BandwidthLimitedStream.disable_bandwidth_limiting�s��+0��(�(�(rc��|js|j�|��S|xj|z
c_|j|jkr|j�|��S|���|j�|��S)zhRead a specified amount

        Reads will only be throttled if bandwidth limiting is enabled.
        )r4r2�readr6r7�_consume_through_leaky_bucket)r
�amounts  r
r>zBandwidthLimitedStream.read�s���
�/�	.��=�%�%�f�-�-�-�	
���F�"�����d�3�3�3��=�%�%�f�-�-�-��*�*�,�,�,��}�!�!�&�)�)�)rc��|jjsq	|j�|j|j��d|_dS#t$r)}|j�|j	��Yd}~nd}~wwxYw|jj�q|jj�)Nr)
r3�	exceptionr"�consumer6r5rr#rr)r
�es  r
r?z4BandwidthLimitedStream._consume_through_leaky_bucket�s����,�6�
	7�
5��"�*�*��$�d�&9����$%�� ����+�
5�
5�
5�� �&�&�q�|�4�4�4�4�4�4�4�4�����
5�����,�6�
	7��,�6�6s�,<�
A/�A*�*A/c�.�|���dS)z6Signal that data being read is being transferred to S3N)r;rs r
�signal_transferringz*BandwidthLimitedStream.signal_transferring�s���&�&�(�(�(�(�(rc�.�|���dS)z:Signal that data being read is not being transferred to S3N)r(rs r
�signal_not_transferringz.BandwidthLimitedStream.signal_not_transferring�s���'�'�)�)�)�)�)rrc�<�|j�||��dSr.)r2�seek)r
�where�whences   r
rJzBandwidthLimitedStream.seek�s ���
���5�&�)�)�)�)�)rc�4�|j���Sr.)r2�tellrs r
rNzBandwidthLimitedStream.tell�s���}�!�!�#�#�#rc�|�|jr|jr|���|j���dSr.)r4r6r?r2�closers r
rPzBandwidthLimitedStream.close�sE���+�	1��0@�	1�
�.�.�0�0�0��
�������rc��|Sr.rrs r
�	__enter__z BandwidthLimitedStream.__enter__�s���rc�.�|���dSr.)rP)r
�args�kwargss   r
�__exit__zBandwidthLimitedStream.__exit__�s���
�
�����r)Nr0)r)rrrr	r;r(r>r?rFrHrJrNrPrRrVrrr
r'r'cs��������"�
!0�!0�!0�!0�F0�0�0�1�1�1�*�*�*�(7�7�7�$)�)�)�*�*�*�*�*�*�*�$�$�$�����������rr'c�:�eZdZ			dd�Zd�Zd�Zd�Zd�Zd�ZdS)	�LeakyBucketNc�
�t|��|_||_|�t��|_t	j��|_||_|�t��|_||_	|�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_rater#r�	threading�Lock�_lock�
_rate_tracker�BandwidthRateTracker�_consumption_scheduler�ConsumptionScheduler)r
�max_rater%�rate_tracker�consumption_schedulers     r
r	zLeakyBucket.__init__�s���.�x�����%�����(�{�{�D���^�%�%��
�)�����!5�!7�!7�D��&;��#� �(�*>�*@�*@�D�'�'�'�)�(rc��|j5|j���}|j�|��r#|�|||��cddd��S|�||��r|�|||��n"|�||��cddd��S	ddd��dS#1swxYwYdS)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^r#rra�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
rCzLeakyBucket.consume�s���$�Z�	B�	B��'�,�,�.�.�H��*�7�7�
�F�F�	
B��H�H������	B�	B�	B�	B�	B�	B�	B�	B��3�3�C��B�B�
B��6�6���������2�2�3��A�A�	B�	B�	B�	B�	B�	B�	B�	B��	B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B����	B�	B�	B�	B�	B�	Bs�A
B=�AB=�=C�Cc�N�|j�||��}||jkSr.)r_�get_projected_rater[)r
rmro�projected_rates    r
riz)LeakyBucket._projected_to_exceed_max_rates'���+�>�>�s�H�M�M�����.�.rc�b�|j�|��|�||��Sr.)ra�process_scheduled_consumptionrkrls    r
rhz8LeakyBucket._release_requested_amt_for_scheduled_requests:��	
�#�A�A��	
�	
�	
��*�*�3��9�9�9rc��|t|j��z}|j�|||��}t	||����)N)rr)rZr[ra�schedule_consumptionr)r
rmrnro�allocated_timers      r
rjz-LeakyBucket._raise_request_exceeded_exception#sS���u�T�^�4�4�4���0�E�E����
�
�
�'��*�
�
�
�	
rc�<�|j�||��|Sr.)r_�record_consumption_rate)r
rmros   r
rkz"LeakyBucket._release_requested_amt,s ����2�2�3��A�A�A��
r)NNN)	rrrr	rCrirhrjrkrrr
rXrX�s���������"�!A�!A�!A�!A�FB�B�B�>/�/�/�:�:�:�
�
�
�����rrXc�&�eZdZd�Zd�Zd�Zd�ZdS)rbc�"�i|_d|_dS)z*Schedules when to consume a desired amountrN)� _tokens_to_scheduled_consumption�_total_waitrs r
r	zConsumptionScheduler.__init__2s��02��-�����rc��||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
�tokens  r
rgz!ConsumptionScheduler.is_scheduled7s����=�=�=rc�T�|xj|z
c_|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)r}r|)r
rmrr�s    r
rvz)ConsumptionScheduler.schedule_consumption@s@��&	
���O�+���!�-�.�8
�8
��-�e�4���rc��|j�|��}t|j|dz
d��|_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.
        r�rN)r|�pop�maxr})r
r�scheduled_retrys   r
rtz2ConsumptionScheduler.process_scheduled_consumptionZsE���?�C�C�E�J�J������/@�A�A�1�
�
����rN)rrrr	rgrvrtrrr
rbrb1sP���������
>�>�>� � � �4

�

�

�

�

rrbc�D�eZdZd	d�Zed���Zd�Zd�Zd�Zd�Z	dS)
r`皙�����?c�0�||_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
�alphas  r
r	zBandwidthRateTracker.__init__hs ��������!����rc�"�|j�dS|jS)zmThe current transfer rate

        :rtype: float
        :returns: The current tracked transfer rate
        N�)r�r�rs r
�current_ratez!BandwidthRateTracker.current_ratexs���?�"��3��!�!rc�@�|j�dS|�||��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
        Nr�)r��*_calculate_exponential_moving_average_rate�r
rm�time_at_consumptions   r
rqz'BandwidthRateTracker.get_projected_rate�s/���?�"��3��>�>��$�
�
�	
rc�x�|j�||_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
        Nr�)r�r�r�r�s   r
ryz,BandwidthRateTracker.record_consumption_rate�sK���?�"�1�D�O�!$�D���F�!�L�L��$�
�
���.����rc�J�||jz
}|dkrtd��S||zS)Nr�inf)r�rZ)r
rmr��
time_deltas    r
�_calculate_ratez$BandwidthRateTracker._calculate_rate�s0��(�4�?�:�
���?�?�
��<�<���j�!�!rc�h�|�||��}|j|zd|jz
|jzzS)N�)r�r�r�)r
rmr��new_rates    r
r�z?BandwidthRateTracker._calculate_exponential_moving_average_rate�s:���'�'��-@�A�A���{�X�%��T�[��D�<N�(N�N�NrN)r�)
rrrr	�propertyr�rqryr�r�rrr
r`r`gs�������"�"�"�"� �"�"��X�"�
�
�
�$.�.�.�$"�"�"�O�O�O�O�Orr`)r\r�	Exceptionrrrr r'rXrbr`rrr
�<module>r�s����������������y����(	�	�	�	�	�	�	�	�!�!�!�!�!�!�!�!�$#�#�#�#�#�#�#�#�Ln�n�n�n�n�n�n�n�bZ�Z�Z�Z�Z�Z�Z�Z�z3
�3
�3
�3
�3
�3
�3
�3
�lNO�NO�NO�NO�NO�NO�NO�NO�NO�NOr