HEX
Server: LiteSpeed
System: Linux server.nevid-deploma.com 4.18.0-553.111.1.lve.el8.x86_64 #1 SMP Fri Mar 13 13:42:17 UTC 2026 x86_64
User: smilepac (1037)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/cppython/lib/python3.8/site-packages/botocore/__pycache__/retryhandler.cpython-38.pyc
U

KD�gn9�@s ddlZddlZddlZddlmZddlmZmZmZm	Z	m
Z
e�e�Z
deee
e	giZdd�Zdd�Zd%d	d
�Zd&dd�Zd'd
d�Zdd�Zdd�Zdd�ZGdd�d�ZGdd�d�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd �d e�ZGd!d"�d"e�ZGd#d$�d$e�ZdS)(�N)�crc32)�
ChecksumError�ConnectionClosedError�ConnectionError�EndpointConnectionError�ReadTimeoutErrorZGENERAL_CONNECTION_ERRORcCs<|dkrt��}n|dkr(td|����|||d}|S)a1Calculate time to sleep based on exponential function.

    The format is::

        base * growth_factor ^ (attempts - 1)

    If ``base`` is set to 'rand' then a random number between
    0 and 1 will be used as the base.
    Base must be greater than 0, otherwise a ValueError will be
    raised.

    Zrandrz.The 'base' param must be greater than 0, got: �)�random�
ValueError)�base�
growth_factor�attemptsZ
time_to_sleep�r�B/opt/cppython/lib/python3.8/site-packages/botocore/retryhandler.py�delay_exponential+s

�rcCstjt||d�S)z�Create an exponential delay function based on the attempts.

    This is used so that you only have to pass it the attempts
    parameter to calculate the delay.

    �rr)�	functools�partialrrrrr�!create_exponential_delay_functionBs
�rcCs$t||d�}t||d�}t||d�S)N)�operation_name)�checker�action)� create_checker_from_retry_config�create_retry_action_from_config�RetryHandler)�configrrrrrr�create_retry_handlerNs��rcCs0|dd}|ddkr,t|d|dd�SdS)N�__default__�delay�typeZexponentialrrr)r)rrZdelay_configrrrrXs�rcCsg}d}g}d|krj|d�dg�}|dd}|D]4}||}|�t|��t|�}|dk	r4|�|�q4|dk	r�|�|�dk	r�||d}	|	D]4}|�t|	|��t|	|�}|dk	r�|�|�q�t|�dkr�t|d|d�St|�}
t|
|t|�d�SdS)Nr�policies�max_attemptsrr)r!)r!�retryable_exceptions)	�get�append�_create_single_checker�_extract_retryable_exception�extend�len�MaxAttemptsDecorator�MultiChecker�tuple)rr�checkersr!r"r �keyZcurrent_configZretry_exceptionZoperation_policiesZ
multi_checkerrrrres:��rcCs2d|dkrt|dd�Sd|dkr.t�SdS)N�response�applies_when�
socket_errors)�_create_single_response_checker�ExceptionRaiser)rrrrr%�s
�r%cCsZd|krt|d|dd�}n8d|kr6t|dd�}n d|krNt|dd�}ntd��|S)NZservice_error_codeZhttp_status_code)�status_code�
error_code)r3�	crc32body)�headerzUnknown retry policy)�ServiceErrorCodeChecker�HTTPStatusCodeChecker�CRC32Checkerr
)r.rrrrr1�s��r1cCsN|d}d|�di�krtgSd|krJg}|dD]}|�t|�q2|SdS)Nr/r5r.r0)r#rr'�
EXCEPTION_MAP)rr/�
exceptions�namerrrr&�sr&c@s eZdZdZdd�Zdd�ZdS)ra�Retry handler.

    The retry handler takes two params, ``checker`` object
    and an ``action`` object.

    The ``checker`` object must be a callable object and based on a response
    and an attempt number, determines whether or not sufficient criteria for
    a retry has been met.  If this is the case then the ``action`` object
    (which also is a callable) determines what needs to happen in the event
    of a retry.

    cCs||_||_dS�N)�_checker�_action)�selfrrrrr�__init__�szRetryHandler.__init__cKsn|||d�}t|jt�r8|dd�d�}|�d|i�|jf|�r`|j|d�}t�d|�|St�d�d	S)
z�Handler for a retry.

        Intended to be hooked up to an event handler (hence the **kwargs),
        this will process retries appropriately.

        )�attempt_numberr.�caught_exceptionZrequest_dict�context�retries�retries_context)r
zRetry needed, action of: %szNo retry needed.N)�
isinstancer>r)r#�updater?�logger�debug)r@r
r.rC�kwargsZchecker_kwargsrF�resultrrr�__call__�s�zRetryHandler.__call__N)�__name__�
__module__�__qualname__�__doc__rArMrrrrr�s
rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�BaseCheckerz�Base class for retry checkers.

    Each class is responsible for checking a single criteria that determines
    whether or not a retry should not happen.

    cCs4|dk	r|�||�S|dk	r(|�||�Std��dS)a�Determine if retry criteria matches.

        Note that either ``response`` is not None and ``caught_exception`` is
        None or ``response`` is None and ``caught_exception`` is not None.

        :type attempt_number: int
        :param attempt_number: The total number of times we've attempted
            to send the request.

        :param response: The HTTP response (if one was received).

        :type caught_exception: Exception
        :param caught_exception: Any exception that was caught while trying to
            send the HTTP response.

        :return: True, if the retry criteria matches (and therefore a retry
            should occur.  False if the criteria does not match.

        Nz,Both response and caught_exception are None.)�_check_response�_check_caught_exceptionr
)r@rBr.rCrrrrM�s�zBaseChecker.__call__cCsdSr=r�r@rBr.rrrrS�szBaseChecker._check_responsecCsdSr=r�r@rBrCrrrrTsz#BaseChecker._check_caught_exceptionN)rNrOrPrQrMrSrTrrrrrR�srRc@s*eZdZdZd	dd�Zdd�Zdd�ZdS)
r)a�Allow retries up to a maximum number of attempts.

    This will pass through calls to the decorated retry checker, provided
    that the number of attempts does not exceed max_attempts.  It will
    also catch any retryable_exceptions passed in.  Once max_attempts has
    been exceeded, then False will be returned or the retryable_exceptions
    that was previously being caught will be raised.

    NcCs||_||_||_dSr=)r>�
_max_attempts�_retryable_exceptions)r@rr!r"rrrrAszMaxAttemptsDecorator.__init__cCsz|rt|�dd�|j�|d<|�|||�}|rr||jkrl|dk	r\d|dkr\d|ddd<t�d|�dS|SndSdS)	N�maxrZResponseMetadatarTZMaxAttemptsReachedz0Reached the maximum number of retry attempts: %sF)rYr#rW�
_should_retryrIrJ)r@rBr.rCrFZshould_retryrrrrMs,
��
��zMaxAttemptsDecorator.__call__c
Csp|jr^||jkr^z|�|||�WS|jk
rZ}ztjd|dd�WY�dSd}~XYqlXn|�|||�SdS)Nz,retry needed, retryable exception caught: %sT)�exc_info)rXrWr>rIrJ)r@rBr.rC�errrrZ0s��z"MaxAttemptsDecorator._should_retry)N)rNrOrPrQrArMrZrrrrr)s

r)c@seZdZdd�Zdd�ZdS)r8cCs
||_dSr=)�_status_code)r@r3rrrrADszHTTPStatusCodeChecker.__init__cCs*|dj|jkr"t�d|j�dSdSdS)Nrz5retry needed: retryable HTTP status code received: %sTF)r3r]rIrJrUrrrrSGs�z%HTTPStatusCodeChecker._check_responseN�rNrOrPrArSrrrrr8Csr8c@seZdZdd�Zdd�ZdS)r7cCs||_||_dSr=)r]�_error_code)r@r3r4rrrrASsz ServiceErrorCodeChecker.__init__cCsJ|dj|jkrF|d�di��d�}||jkrFt�d|j|j�dSdS)Nrr�ErrorZCodez>retry needed: matching HTTP status and error code seen: %s, %sTF)r3r]r#r_rIrJ)r@rBr.Zactual_error_coderrrrSWs
�z'ServiceErrorCodeChecker._check_responseNr^rrrrr7Rsr7c@seZdZdd�Zdd�ZdS)r*cCs
||_dSr=�Z	_checkers)r@r,rrrrAfszMultiChecker.__init__cCs(|jD]}||||�}|r|SqdS)NFra)r@rBr.rCrZchecker_responserrrrMis
�
zMultiChecker.__call__N)rNrOrPrArMrrrrr*esr*c@seZdZdd�Zdd�ZdS)r9cCs
||_dSr=)�_header_name)r@r6rrrrAtszCRC32Checker.__init__cCst|d}|j�|j�}|dkr.t�d|j�nBt|dj�d@}|t|�kspt�dt|�|�tdt|�|d��dS)Nrz?crc32 check skipped, the %s header is not in the http response.l��z>retry needed: crc32 check failed, expected != actual: %s != %sr)Z
checksum_typeZexpected_checksumZactual_checksum)	�headersr#rbrIrJr�content�intr)r@rBr.�
http_responseZexpected_crcZactual_crc32rrrrSxs&���zCRC32Checker._check_responseNr^rrrrr9ssr9c@seZdZdZdd�ZdS)r2z`Raise any caught exceptions.

    This class will raise any non None ``caught_exception``.

    cCs|�dSr=rrVrrrrT�sz'ExceptionRaiser._check_caught_exceptionN)rNrOrPrQrTrrrrr2�sr2)N)N)N)r�loggingr	�binasciirZbotocore.exceptionsrrrrr�	getLoggerrNrIr:rrrrrr%r1r&rrRr)r8r7r*r9r2rrrr�<module>s8
��




"	).?