HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: sport3497 (1034)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib/python3.10/site-packages/botocore/__pycache__/retryhandler.cpython-310.pyc
o

�hn9�@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�ReadTimeoutError�GENERAL_CONNECTION_ERRORcCs<|dkr	t��}n|dkrtd|����|||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.

    �randrz.The 'base' param must be greater than 0, got: �)�random�
ValueError)�base�
growth_factor�attempts�
time_to_sleep�r�H/usr/local/CyberCP/lib/python3.10/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.

    �r
r)�	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}|ddkrt|d|dd�SdS)N�__default__�delay�type�exponentialr
rr)r)rr�delay_configrrrrXs��rcCs�g}d}g}d|vr5|d�dg�}|dd}|D]}||}|�t|��t|�}|dur4|�|�q|durc|�|�durc||d}	|	D]}|�t|	|��t|	|�}|durb|�|�qHt|�dkrqt|d|d�St|�}
t|
|t|�d�S)Nr �policies�max_attemptsr
r)r&)r&�retryable_exceptions)	�get�append�_create_single_checker�_extract_retryable_exception�extend�len�MaxAttemptsDecorator�MultiChecker�tuple)rr�checkersr&r'r%�key�current_config�retry_exception�operation_policies�
multi_checkerrrrres>
��
��rcCs2d|dvrt|dd�Sd|dvrt�SdS)N�response�applies_when�
socket_errors)�_create_single_response_checker�ExceptionRaiser)rrrrr*�s
��r*cCs\d|vrt|d|dd�}|Sd|vrt|dd�}|Sd|vr*t|dd�}|Std��)N�service_error_code�http_status_code)�status_code�
error_code)r>�	crc32body)�headerzUnknown retry policy)�ServiceErrorCodeChecker�HTTPStatusCodeChecker�CRC32Checkerr)r7rrrrr:�s�
����r:cCsN|d}d|�di�vrtgSd|vr%g}|dD]	}|�t|�q|SdS)Nr8r@r7r9)r(rr,�
EXCEPTION_MAP)rr8�
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.

    cC�||_||_dS�N)�_checker�_action)�selfrrrrr�__init__��
zRetryHandler.__init__cKsr|||d�}t|jt�r|dd�d�}|�d|i�|jd
i|��r2|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_numberr7�caught_exception�request_dict�context�retries�retries_context)rzRetry needed, action of: %szNo retry needed.Nr)�
isinstancerJr.r(�updaterK�logger�debug)rLrr7rP�kwargs�checker_kwargsrT�resultrrr�__call__�s�zRetryHandler.__call__N)�__name__�
__module__�__qualname__�__doc__rMr\rrrrr�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.

    cCs0|dur
|�||�S|dur|�||�Std��)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)rLrOr7rPrrrr\�s�zBaseChecker.__call__cC�dSrIr�rLrOr7rrrrb��zBaseChecker._check_responsecCrdrIr�rLrOrPrrrrcrfz#BaseChecker._check_caught_exceptionN)r]r^r_r`r\rbrcrrrrra�s
rac@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||_||_||_dSrI)rJ�
_max_attempts�_retryable_exceptions)rLrr&r'rrrrMs
zMaxAttemptsDecorator.__init__cCst|rt|�dd�|j�|d<|�|||�}|r8||jkr6|dur.d|dvr.d|ddd<t�d|�dS|SdS)	N�maxr�ResponseMetadatar
T�MaxAttemptsReachedz0Reached the maximum number of retry attempts: %sF)rjr(rh�
_should_retryrWrX)rLrOr7rPrT�should_retryrrrr\s&��
��zMaxAttemptsDecorator.__call__c
Csh|jr-||jkr-z|�|||�WS|jy,}ztjd|dd�WYd}~dSd}~ww|�|||�S)Nz,retry needed, retryable exception caught: %sT)�exc_info)rirhrJrWrX)rLrOr7rP�errrrm0s����
z"MaxAttemptsDecorator._should_retryrI)r]r^r_r`rMr\rmrrrrr.s


r.c@�eZdZdd�Zdd�ZdS)rCcC�
||_dSrI)�_status_code)rLr>rrrrMD�
zHTTPStatusCodeChecker.__init__cCs&|dj|jkrt�d|j�dSdS)Nrz5retry needed: retryable HTTP status code received: %sTF)r>rsrWrXrerrrrbGs�z%HTTPStatusCodeChecker._check_responseN�r]r^r_rMrbrrrrrCC�rCc@rq)rBcCrHrI)rs�_error_code)rLr>r?rrrrMSrNz ServiceErrorCodeChecker.__init__cCsJ|dj|jkr#|d�di��d�}||jkr#t�d|j|j�dSdS)Nrr
�Error�Codez>retry needed: matching HTTP status and error code seen: %s, %sTF)r>rsr(rwrWrX)rLrOr7�actual_error_coderrrrbWs
�z'ServiceErrorCodeChecker._check_responseNrurrrrrBR�rBc@rq)r/cCrrrI��	_checkers)rLr1rrrrMfrtzMultiChecker.__init__cCs(|jD]}||||�}|r|SqdS)NFr|)rLrOr7rPr�checker_responserrrr\is
��zMultiChecker.__call__N)r]r^r_rMr\rrrrr/ervr/c@rq)rDcCrrrI)�_header_name)rLrArrrrMts
zCRC32Checker.__init__cCsv|d}|j�|j�}|durt�d|j�dSt|dj�d@}|t|�ks9t�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)�
checksum_type�expected_checksum�actual_checksum)	�headersr(rrWrXr�content�intr)rLrOr7�
http_response�expected_crc�actual_crc32rrrrbxs(����zCRC32Checker._check_responseNrurrrrrDsr{rDc@seZdZdZdd�ZdS)r;z`Raise any caught exceptions.

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

    cCs|�rIrrgrrrrc�sz'ExceptionRaiser._check_caught_exceptionN)r]r^r_r`rcrrrrr;�sr;rI)r�loggingr�binasciir�botocore.exceptionsrrrrr�	getLoggerr]rWrErrrrrr*r:r+rrar.rCrBr/rDr;rrrr�<module>s:
��





"	).?