HEX
Server: LiteSpeed
System: Linux us-phx-web1284.main-hosting.eu 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: u300739242 (300739242)
PHP: 8.2.30
Disabled: system, 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
�

/�;f=����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���||_||_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
        z<Request amount {} exceeded the amount available. Retry in {}N)�
requested_amt�
retry_time�format�super�__init__)�selfrr�msg�	__class__s    ��G/opt/alt/python311/lib/python3.11/site-packages/s3transfer/bandwidth.pyr
z!RequestExceededException.__init__sN���+���$���L�S�S��:�
�
��	�����������)�__name__�
__module__�__qualname__r
�
__classcell__)r
s@rrrs8���������������rrc��eZdZdZdS)�RequestTokenzDA token to pass as an identifier when consuming from the LeakyBucketN)rrr�__doc__�rrrr's������N�N��Drrc��eZdZd�Zd�ZdS)�	TimeUtilsc�(�tj��S)zgGet the current time back

        :rtype: float
        :returns: The current time in seconds
        )�time�rs rrzTimeUtils.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  rrzTimeUtils.sleep6s���z�%� � � rN)rrrrrrrrrr-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   rr
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_streamNsD��(��T�'�)=�t�?O�
�
���	0��-�-�/�/�/��
r�N)T)rrrr
r.rrrr!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)rr*r%r+r&�bytes_thresholds      rr
zBandwidthLimitedStream.__init__fs_��0 ��
�)���%9��"�%�����(�{�{�D��+/��(�*�n�n������ /����rc��d|_dS)z0Enable bandwidth limiting on reads to the streamTN�r5rs r�enable_bandwidth_limitingz0BandwidthLimitedStream.enable_bandwidth_limiting�s��+/��(�(�(rc��d|_dS)z1Disable bandwidth limiting on reads to the streamFNr;rs rr)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.
        )r5r3�readr7r8�_consume_through_leaky_bucket)r�amounts  rr?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)
r4�	exceptionr#�consumer7r6rr$rr)r�es  rr@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/)r3�seek)r�where�whences   rrKzBandwidthLimitedStream.seek�s ���
���5�&�)�)�)�)�)rc�4�|j���Sr/)r3�tellrs rrOzBandwidthLimitedStream.tell�s���}�!�!�#�#�#rc�|�|jr|jr|���|j���dSr/)r5r7r@r3�closers rrQzBandwidthLimitedStream.close�sE���+�	1��0@�	1�
�.�.�0�0�0��
�������rc��|Sr/rrs r�	__enter__z BandwidthLimitedStream.__enter__�s���rc�.�|���dSr/)rQ)r�args�kwargss   r�__exit__zBandwidthLimitedStream.__exit__�s���
�
�����r)Nr1)r)rrrr
r<r)r?r@rGrIrKrOrQrSrWrrrr(r(es��������"�
!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     rr
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$rrb�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    rrDzLeakyBucket.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\)rrnrp�projected_rates    rrjz)LeakyBucket._projected_to_exceed_max_rates'���+�>�>�s�H�M�M�����.�.rc�b�|j�|��|�||��Sr/)rb�process_scheduled_consumptionrlrms    rriz8LeakyBucket._release_requested_amt_for_scheduled_requests:��	
�#�A�A��	
�	
�	
��*�*�3��9�9�9rc��|t|j��z}|j�|||��}t	||����)N)rr)r[r\rb�schedule_consumptionr)rrnrorp�allocated_timers      rrkz-LeakyBucket._raise_request_exceeded_exception%sS���u�T�^�4�4�4���0�E�E����
�
�
�'��*�
�
�
�	
rc�<�|j�||��|Sr/)r`�record_consumption_rate)rrnrps   rrlz"LeakyBucket._release_requested_amt.s ����2�2�3��A�A�A��
r)NNN)	rrrr
rDrjrirkrlrrrrYrY�s���������"�!A�!A�!A�!A�FB�B�B�>/�/�/�:�:�:�
�
�
�����rrYc�&�eZdZd�Zd�Zd�Zd�ZdS)rcc�"�i|_d|_dS)z*Schedules when to consume a desired amountrN)� _tokens_to_scheduled_consumption�_total_waitrs rr
zConsumptionScheduler.__init__4s��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  rrhz!ConsumptionScheduler.is_scheduled9s����=�=�=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})rrnr�r�s    rrwz)ConsumptionScheduler.schedule_consumptionBs@��&	
���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~)rr��scheduled_retrys   rruz2ConsumptionScheduler.process_scheduled_consumption\sE���?�C�C�E�J�J������/@�A�A�1�
�
����rN)rrrr
rhrwrurrrrcrc3sP���������
>�>�>� � � �4

�

�

�

�

rrcc�D�eZdZd	d�Zed���Zd�Zd�Zd�Zd�Z	dS)
ra皙�����?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  rr
zBandwidthRateTracker.__init__js ��������!����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_ratezs���?�"��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�rrn�time_at_consumptions   rrrz'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   rrzz,BandwidthRateTracker.record_consumption_rate�sK���?�"�1�D�O�!$�D���F�!�L�L��$�
�
���.����rc�J�||jz
}|dkrtd��S||zS)Nr�inf)r�r[)rrnr��
time_deltas    r�_calculate_ratez$BandwidthRateTracker._calculate_rate�s0��(�4�?�:�
���?�?�
��<�<���j�!�!rc�h�|�||��}|j|zd|jz
|jzzS)N�)r�r�r�)rrnr��new_rates    rr�z?BandwidthRateTracker._calculate_exponential_moving_average_rate�s:���'�'��-@�A�A���{�X�%��T�[��D�<N�(N�N�NrN)r�)
rrrr
�propertyr�rrrzr�r�rrrrarais�������"�"�"�"� �"�"��X�"�
�
�
�$.�.�.�$"�"�"�O�O�O�O�Orra)r]r�	Exceptionrrrr!r(rYrcrarrr�<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