HEX
Server: nginx/1.24.0
System: Linux webserver 6.8.0-85-generic #85-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 18 15:26:59 UTC 2025 x86_64
User: wpuser (1002)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/botocore/retries/__pycache__/standard.cpython-312.pyc
�

P��eN���dZddlZddlZddlmZmZmZmZddlm	Z	m
Z
ddlmZm
Z
dZeje�Zefd�ZGd�d	�ZGd
�d�ZGd�d
�ZGd�d�ZGd�de
�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�d�ZGd�d�ZGd�de�ZGd �d!e�ZGd"�d#�Z y)$aCStandard retry behavior.

This contains the default standard retry behavior.
It provides consistent behavior with other AWS SDKs.

The key base classes uses for retries:

    * ``BaseRetryableChecker`` - Use to check a specific condition that
    indicates a retry should happen.  This can include things like
    max attempts, HTTP status code checks, error code checks etc.
    * ``RetryBackoff`` - Use to determine how long we should backoff until
    we retry a request.  This is the class that will implement delay such
    as exponential backoff.
    * ``RetryPolicy`` - Main class that determines if a retry should
    happen.  It can combine data from a various BaseRetryableCheckers
    to make a final call as to whether or not a retry should happen.
    It then uses a ``BaseRetryBackoff`` to determine how long to delay.
    * ``RetryHandler`` - The bridge between botocore's event system
    used by endpoint.py to manage retries and the interfaces defined
    in this module.

This allows us to define an API that has minimal coupling to the event
based API used by botocore.

�N)�ConnectionError�ConnectTimeoutError�HTTPClientError�ReadTimeoutError)�quota�special)�BaseRetryableChecker�BaseRetryBackoff�c���ttj��}|jjj
}|j
�}|jjjd|��|j�ttt|��t���t�|��}d|z}|jjjd|z|j|��|S)Nzafter-call.)�max_attempts)�
retry_checker�
retry_backoff)�retry_policy�retry_event_adapter�retry_quotazretry-config-%szneeds-retry.%s)�	unique_id)�RetryQuotaCheckerr�
RetryQuota�meta�
service_model�
service_id�	hyphenize�events�register�release_retry_quota�RetryHandler�RetryPolicy�StandardRetryConditions�ExponentialBackoff�RetryEventAdapter�needs_retry)�clientr
rr�service_event_name�handlerrs       �;/usr/lib/python3/dist-packages/botocore/retries/standard.py�register_retry_handlerr'*s���#�E�$4�$4�$6�7�K����*�*�5�5�J�#�-�-�/��
�K�K�����
�(�)�*�K�,K�,K��� �1�|�L�,�.�
�.�/��
�G�"�$6�6�I�
�K�K������-�-����� ��
�N�c��eZdZdZd�Zd�Zy)rz�Bridge between botocore's event system and this module.

    This class is intended to be hooked to botocore's event system
    as an event handler.
    c�.�||_||_||_y�N)�
_retry_policy�_retry_event_adapter�_retry_quota)�selfrrrs    r&�__init__zRetryHandler.__init__Ls��)���$7��!�'��r(c��d}|jjdi|��}|jj|�rc|jj|�r2|jj
|�}tjd|�n+tjd�ntjd�|jj|�|S)z.Connect as a handler to the needs-retry event.Nz1Retry needed, retrying request after delay of: %sz;Retry needed but retry quota reached, not retrying request.zNot retrying request.�)
r-�create_retry_contextr,�should_retryr.�acquire_retry_quota�compute_retry_delay�logger�debug�!adapt_retry_response_from_context)r/�kwargs�retry_delay�contexts    r&r"zRetryHandler.needs_retryQs�����@�$�+�+�@�@�J�6�J�����*�*�7�3�� � �4�4�W�=�"�0�0�D�D�W�M�����G���
���,��

�L�L�0�1��!�!�C�C�G�L��r(N)�__name__�
__module__�__qualname__�__doc__r0r"r2r(r&rrEs���(�
r(rc��eZdZdZd�Zd�Zy)r!a{Adapter to existing retry interface used in the endpoints layer.

    This existing interface for determining if a retry needs to happen
    is event based and used in ``botocore.endpoint``.  The interface has
    grown organically over the years and could use some cleanup.  This
    adapter converts that interface into the interface used by the
    new retry strategies.

    c	�h�|d}|�d}d}n|\}}t|d|d|||d|dd��}|S)	z+Create context based on needs-retry kwargs.�responseN�attempts�	operation�caught_exception�request_dictr<)�attempt_number�operation_model�
http_response�parsed_responserF�request_context)�RetryContext)r/r:rCrJrKr<s      r&r3z&RetryEventAdapter.create_retry_contexttsg���*�%����
!�M�"�O�-5�*�M�?��!�*�-�"�;�/�'�+�#�$6�7�"�>�2�9�=�

���r(c��|j�}|j�,|jjdi�j|�yy)z/Modify response back to user back from context.N�ResponseMetadata)�get_retry_metadatarK�
setdefault�update)r/r<�metadatas   r&r9z3RetryEventAdapter.adapt_retry_response_from_context�sH��
�-�-�/���"�"�.��#�#�.�.�/A�2�F�M�M��
�/r(N)r=r>r?r@r3r9r2r(r&r!r!is����2	r(r!c�4�eZdZdZ					dd�Zd�Zd�Zd�Zy)rMa�Normalize a response that we use to check if a retry should occur.

    This class smoothes over the different types of responses we may get
    from a service including:

        * A modeled error response from the service that contains a service
          code and error message.
        * A raw HTTP response that doesn't contain service protocol specific
          error keys.
        * An exception received while attempting to retrieve a response.
          This could be a ConnectionError we receive from our HTTP layer which
          could represent that we weren't able to receive a response from
          the service.

    This class guarantees that at least one of the above attributes will be
    non None.

    This class is meant to provide a read-only view into the properties
    associated with a possible retryable response.  None of the properties
    are meant to be modified directly.

    Nc�n�||_||_||_||_||_|�i}||_i|_yr+)rHrIrKrJrFrL�_retry_metadata)r/rHrIrKrJrFrLs       r&r0zRetryContext.__init__�sM��-���.��� /���*���!1���
�"� �O�.���!��r(c��|j�y|jjdi�}t|t�sy|jd�S)z�Check if there was a parsed response with an error code.

        If we could not find any error codes, ``None`` is returned.

        N�Error�Code)rK�get�
isinstance�dict)r/�errors  r&�get_error_codezRetryContext.get_error_code�sG�����'���$�$�(�(��"�5���%��&���y�y�� � r(c�<�|jjdi|��y)z�Add key/value pairs to the retry metadata.

        This allows any objects during the retry process to add
        metadata about any checks/validations that happened.

        This gets added to the response metadata in the retry handler.

        Nr2)rVrR)r/r:s  r&�add_retry_metadatazRetryContext.add_retry_metadata�s��	$����#�#�-�f�-r(c�6�|jj�Sr+)rV�copy�r/s r&rPzRetryContext.get_retry_metadata�s���#�#�(�(�*�*r()NNNNN)r=r>r?r@r0r^r`rPr2r(r&rMrM�s,���4�����"�>!�	.�+r(rMc��eZdZd�Zd�Zd�Zy)rc� �||_||_yr+)�_retry_checker�_retry_backoff)r/rrs   r&r0zRetryPolicy.__init__�s��+���+��r(c�8�|jj|�Sr+)rf�is_retryable�r/r<s  r&r4zRetryPolicy.should_retry�����"�"�/�/��8�8r(c�8�|jj|�Sr+)rg�delay_amountrjs  r&r6zRetryPolicy.compute_retry_delay�rkr(N)r=r>r?r0r4r6r2r(r&rr�s��,�9�9r(rc�:�eZdZdZdZdej
fd�Zd�Zy)r ��c�B�|j|_||_||_yr+)�_BASE�_base�_max_backoff�_random)r/�max_backoff�randoms   r&r0zExponentialBackoff.__init__�s���Z�Z��
�'�����r(c��t|j�|j|jdz
zz|j�S)aCalculates delay based on exponential backoff.

        This class implements truncated binary exponential backoff
        with jitter::

            t_i = min(rand(0, 1) * 2 ** attempt, MAX_BACKOFF)

        where ``i`` is the request attempt (0 based).

        �)�minrursrHrtrjs  r&rmzExponentialBackoff.delay_amounts<����L�L�N�d�j�j�W�-C�-C�a�-G�H�I����
�	
r(N)r=r>r?rr�_MAX_BACKOFFrwr0rmr2r(r&r r �s��
�E��L�#%�f�m�m��

r(r c��eZdZd�Zd�Zy)�MaxAttemptsCheckerc��||_yr+)�
_max_attempts�r/r
s  r&r0zMaxAttemptsChecker.__init__s
��)��r(c�,�|j|jk}|jjd�}|r)t	|jdd�|j�|d<|s2t
j
d|j�|jd��|S)N�retries�maxrzMax attempts of %s reached.T)�MaxAttemptsReached)rHrrLrZr�r7r8r`)r/r<�under_max_attempts�retries_contexts    r&rizMaxAttemptsChecker.is_retryables���$�3�3�d�6H�6H�H��!�1�1�5�5�i�@���%(��#�#�E�1�-�t�/A�/A�&�O�E�"�"��L�L�6��8J�8J�K��&�&�$�&�?�!�!r(N�r=r>r?r0rir2r(r&r}r}s��*�
"r(r}c�8�eZdZgd�Zgd�ZeefZ			dd�Zd�Z	y)�TransientRetryableChecker)�RequestTimeout�RequestTimeoutException�PriorRequestNotComplete)i�i�i�i�Nc��|�|jdd}|�|jdd}|�|j}||_||_||_yr+)�_TRANSIENT_ERROR_CODES�_TRANSIENT_STATUS_CODES�_TRANSIENT_EXCEPTION_CLS�_transient_error_codes�_transient_status_codes�_transient_exception_cls)r/�transient_error_codes�transient_status_codes�transient_exception_clss    r&r0z"TransientRetryableChecker.__init__5s\��!�(�$(�$?�$?��$B�!�!�)�%)�%A�%A�!�%D�"�"�*�&*�&C�&C�#�&;��#�'=��$�(?��%r(c���|j�|jvry|j�#|jj|jvry|j
� t
|j
|j�Sy)NTF)r^r�rJ�status_coder�rFr[r�rjs  r&riz&TransientRetryableChecker.is_retryableEsy���!�!�#�t�'B�'B�B��� � �,��%�%�1�1��/�/�0���#�#�/���(�(�$�*G�*G��
�r()NNN)
r=r>r?r�r�rrr�r0rir2r(r&r�r�)s6����
3���� ��#�#� $�	@� 
r(r�c�"�eZdZgd�Zdd�Zd�Zy)�ThrottledRetryableChecker)�
Throttling�ThrottlingException�ThrottledException�RequestThrottledException�TooManyRequestsException�&ProvisionedThroughputExceededException�TransactionInProgressException�RequestLimitExceeded�BandwidthLimitExceeded�LimitExceededException�RequestThrottled�SlowDownr��EC2ThrottledExceptionNc�4�|�|jdd}||_yr+)�_THROTTLED_ERROR_CODES�_throttled_error_codes)r/�throttled_error_codess  r&r0z"ThrottledRetryableChecker.__init__is!�� �(�$(�$?�$?��$B�!�&;��#r(c�:�|j�|jvSr+)r^r�rjs  r&riz&ThrottledRetryableChecker.is_retryablens���%�%�'�4�+F�+F�F�Fr(r+)r=r>r?r�r0rir2r(r&r�r�Us����"<�
Gr(r�c��eZdZdZd�Zd�Zy)�ModeledRetryableCheckerz0Check if an error has been modeled as retryable.c�"�t�|_yr+)�ModeledRetryErrorDetector�_error_detectorrcs r&r0z ModeledRetryableChecker.__init__ws
��8�:��r(c�b�|j�}|�y|jj|�duS)NF)r^r��detect_error_type)r/r<�
error_codes   r&riz$ModeledRetryableChecker.is_retryablezs5���+�+�-�
�����#�#�5�5�g�>�d�J�Jr(N)r=r>r?r@r0rir2r(r&r�r�ts��:�;�Kr(r�c��eZdZdZdZdZd�Zy)r�z<Checks whether or not an error is a modeled retryable error.�TRANSIENT_ERROR�THROTTLING_ERRORc��|j�}|j}|�|jsy|jD]�}|jj	d���|jj	di�j	d�xs|j
}||k(s�^|jdj	d�r|jcS|jcSy)aCDetect the error type associated with an error code and model.

        This will either return:

            * ``self.TRANSIENT_ERROR`` - If the error is a transient error
            * ``self.THROTTLING_ERROR`` - If the error is a throttling error
            * ``None`` - If the error is neither type of error.

        N�	retryabler]�code�
throttling)r^rI�error_shapesrSrZ�namer�r�)r/r<r��op_model�shape�error_code_to_checks      r&r�z+ModeledRetryErrorDetector.detect_error_type�s����+�+�-�
��*�*����8�#8�#8���*�*�
	0�E��~�~�!�!�+�.�:��N�N�&�&�w��3�7�7��?�M�5�:�:�$��!4�4��~�~�k�2�6�6�|�D�#�4�4�4��/�/�/�
	0r(N)r=r>r?r@r�r�r�r2r(r&r�r��s��F�(�O�)��
0r(r�c��eZdZd�Zd�Zy)�ThrottlingErrorDetectorc�N�t�|_t�|_||_yr+)r��_modeled_error_detectorr��_fixed_error_code_detectorr-)r/rs  r&r0z ThrottlingErrorDetector.__init__�s ��'@�'B��$�*C�*E��'�$7��!r(c���|jjdi|��}|jj|�ry|jj|�}||jjk(S)NTr2)r-r3r�rir�r�r�)r/r:r<�
error_types    r&�is_throttling_errorz+ThrottlingErrorDetector.is_throttling_error�sa��@�$�+�+�@�@�J�6�J���*�*�7�7��@���1�1�C�C�G�L�
��T�9�9�J�J�J�Jr(N)r=r>r?r0r�r2r(r&r�r��s
��8�Kr(r�c� �eZdZdZefd�Zd�Zy)rz�Concrete class that implements the standard retry policy checks.

    Specifically:

        not max_attempts and (transient or throttled or modeled_retry)

    c
���t|�|_tt�t	�t�tt
j�t
j�g�g�|_	yr+)
r}�_max_attempts_checker�OrRetryCheckerr�r�r�r�RetryIDPCommunicationError�RetryDDBChecksumError�_additional_checkersr�s  r&r0z StandardRetryConditions.__init__�sZ��&8��%E��"�$2�)�+�)�+�'�)���:�:�<��5�5�7���	

�%
��!r(c�r�|jj|�xr|jj|�Sr+)r�rir�rjs  r&riz$StandardRetryConditions.is_retryable�s7���)�)�6�6��
�>��'�'�4�4�W�=�	>r(N)r=r>r?r@�DEFAULT_MAX_ATTEMPTSr0rir2r(r&rr�s���%9�
�$>r(rc��eZdZd�Zd�Zy)r�c��||_yr+)�	_checkers)r/�checkerss  r&r0zOrRetryChecker.__init__�s	��!��r(c�@��t�fd�|jD��S)Nc3�@�K�|]}|j�����y�wr+)ri)�.0�checkerr<s  �r&�	<genexpr>z.OrRetryChecker.is_retryable.<locals>.<genexpr>�s�����O�W�7�'�'��0�O�s�)�anyr�rjs `r&rizOrRetryChecker.is_retryable�s����O����O�O�Or(Nr�r2r(r&r�r��s
��"�Pr(r�c�8�eZdZdZdZdZeefZd�Z	d�Z
d�Zd�Zy)	r�ry�
c� �||_d|_yr+)�_quota�_last_amount_acquired)r/rs  r&r0zRetryQuotaChecker.__init__�s�����%)��"r(c���|j|�r
|j}n|j}|jj	|�}|r||j
d<y|j
d��y)N�retry_quota_capacityT)�RetryQuotaReachedF)�_is_timeout_error�_TIMEOUT_RETRY_REQUEST�_RETRY_COSTr��acquirerLr`)r/r<�capacity_amount�successs    r&r5z%RetryQuotaChecker.acquire_retry_quota�sh���!�!�'�*�"�9�9�O�"�.�.�O��+�+�%�%�o�6���?N�G�#�#�$:�;���"�"�T�"�:�r(c�B�t|j|j�Sr+)r[rF�_TIMEOUT_EXCEPTIONSrjs  r&r�z#RetryQuotaChecker._is_timeout_error�s���'�2�2�D�4L�4L�M�Mr(c���|�y|j}d|cxkrdkrNnyd|vr&|jj|j�y|d}|jj|�yy)N��i,r�)r�r��release�_NO_RETRY_INCREMENT)r/r<rJr:r�r�s      r&rz%RetryQuotaChecker.release_retry_quotasg��� ��#�/�/���+�#��#�%�W�4����#�#�D�$<�$<�=�")�*@�"A�����#�#�O�4�$r(N)
r=r>r?r�r�r�rrr�r0r5r�rr2r(r&rr�s4���K�����.�0@�A��*�

�N�5r(r)!r@�loggingrw�botocore.exceptionsrrrr�botocore.retriesrr�botocore.retries.baser	r
r��	getLoggerr=r7r'rr!rMrr r}r�r�r�r�r�rr�rr2r(r&�<module>r�s����2�
���,�H���	��	�	�8�	$��1E��6!�!�H-�-�fP+�P+�f	9�	9�
�)�
�:"�-�"�")� 4�)�XG� 4�G�>
K�2�
K�"0�"0�JK�K�>�2�>�BP�)�P�55�55r(