HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/libcloud/utils/__pycache__/retry.cpython-310.pyc
o

;j��@s�ddlZddlZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZddgZe�
e�ZdZGd	d
�d
ej�ZdZdZdZeejeje	je	jefZGd
d�d�ZGdd�de�ZGdd�de�ZdS)�N)�datetime�	timedelta��wraps)�httplib)�RateLimitReachedError�Retry�RetryForeverOnRateLimitErrorzThe read operation timed outc@seZdZdZdS)�TransientSSLErrorz-Represent transient SSL errors, e.g. timeoutsN)�__name__�
__module__�__qualname__�__doc__�rr�H/opt/saltstack/salt/lib/python3.10/site-packages/libcloud/utils/retry.pyr
%sr
��c@s,eZdZeeefdd�Zdd�Zdd�ZdS)�MinimalRetrycCsD|durt}|durt}|durt}t|d�}||_||_||_dS)a�
        Wrapper around retrying that helps to handle common transient
        exceptions.

        This minimalistic version only retries SSL errors and rate limiting.

        :param retry_delay: retry delay between the attempts.
        :param timeout: maximum time to wait.
        :param backoff: multiplier added to delay between attempts.

        :Example:

        retry_request = MinimalRetry(timeout=1, retry_delay=1, backoff=1)
        retry_request(self.connection.request)()
        Nr)�
DEFAULT_DELAY�DEFAULT_TIMEOUT�DEFAULT_BACKOFF�max�retry_delay�timeout�backoff)�selfrrrrrr�__init__;s

zMinimalRetry.__init__c�$dd��t�����fdd��}|S)Nc
_�Fz||i|��WStjy"}z
tt|�vrt|j��|�d}~ww�N��ssl�SSLError�TRANSIENT_SSL_ERROR�strr
�args��functionr%�kwargs�excrrr�transform_ssl_error_�
��z2MinimalRetry.__call__.<locals>.transform_ssl_errorc
s��j}t��t�jd�}d}t��|krhz��g|�Ri|��WStya}z4|}t|t�rFt�	d�|j
r;|j
nd}t�|��j}n��
|�rVt�|�|�j9}n�WYd}~nd}~wwt��|ks|�)N��secondsz*You are being rate limited, backing off...�)rr�nowrr�	Exception�
isinstancer�_logger�debug�retry_after�time�sleep�should_retryr)r%r(�
current_delay�end�last_excr)r4��funcrr*rr�
retry_loophs*




���z)MinimalRetry.__call__.<locals>.retry_loopr�rr<r=rr;r�__call__^s	 zMinimalRetry.__call__cCsdS)NFr�r�	exceptionrrrr7�szMinimalRetry.should_retryN)	rrr
rrrrr?r7rrrrr:s
�#-rcs.eZdZeeeef�fdd�	Zdd�Z�Z	S)rcs(t�j|||d�|durt}||_dS)a�
        Wrapper around retrying that helps to handle common transient
        exceptions.

        This version retries the errors that
        `libcloud.utils.retry:MinimalRetry` retries and all errors of the
        exception types that are given.

        :param retry_exceptions: types of exceptions to retry on.
        :param retry_delay: retry delay between the attempts.
        :param timeout: maximum time to wait.
        :param backoff: multiplier added to delay between attempts.

        :Example:

        retry_request = Retry(retry_exceptions=(httplib.NotConnected,),
                              timeout=1, retry_delay=1, backoff=1)
        retry_request(self.connection.request)()
        )rrrN)�superr�RETRY_EXCEPTIONS�retry_exceptions)rrDrrr��	__class__rrr�s
zRetry.__init__cCst|t|j��Sr)r1�tuplerDr@rrrr7�szRetry.should_retry)
rrr
rCrrrrr7�
__classcell__rrrErr�s� c@seZdZdZdd�ZdS)r	a�
    This class is only here for backward compatibility reasons with
    pre-Libcloud v3.3.2.

    If works by ignoring timeout argument and retrying forever until API
    is returning 429 RateLimitReached errors.

    In most cases using this class is not a good idea since it can cause code
    to hang and retry for ever in case API continues to return retry limit
    reached.
    cr)Nc
_rrr r&rrrr*�r+zBRetryForeverOnRateLimitError.__call__.<locals>.transform_ssl_errorc
s��j}t��t�jd�}	z��g|�Ri|��WSty`}z:t|t�r>t�	|j
��j}t��t|j
�jd�}nt��|krE���|�rUt�	|�|�j9}n�WYd}~nd}~wwq)Nr,)
rrr/rrr0r1rr5r6r4r7r)r%r(r8r9r)r;rrr=�s&


���z9RetryForeverOnRateLimitError.__call__.<locals>.retry_looprr>rr;rr?�s	z%RetryForeverOnRateLimitError.__call__N)rrr
rr?rrrrr	�s)r!r5�socket�loggingrr�	functoolsrZlibcloud.utils.py3rZlibcloud.common.exceptionsr�__all__�	getLoggerrr2r#r"r
rrr�error�gaierror�NotConnected�ImproperConnectionStaterCrrr	rrrr�<module>s6�
�
U%