Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/urllib3/util/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/urllib3/util/__pycache__/retry.cpython-311.pyc

�

�܋f�G��0�ddlmZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
mZmZmZmZmZmZddlmZejrdd	lmZdd
lmZeje��ZGd�dej��ZGd
�d��Z e d��e _!dS)�)�annotationsN)�	takewhile)�
TracebackType�)�ConnectTimeoutError�
InvalidHeader�
MaxRetryError�
ProtocolError�
ProxyError�ReadTimeoutError�
ResponseError�)�reraise)�ConnectionPool)�BaseHTTPResponsec�B�eZdZUded<ded<ded<ded<ded<d	S)
�RequestHistory�
str | None�method�url�Exception | None�error�
int | None�status�redirect_locationN)�__name__�
__module__�__qualname__�__annotations__���I/opt/cloudlinux/venv/lib64/python3.11/site-packages/urllib3/util/retry.pyrrsK������������O�O�O���������!�!�!�!�!�!r!rc�:�eZdZUdZegd���Zegd���Zedg��ZdZde	d<dd	d	d	d	d	ed	d
eddd	dedfdQd'�Z
dRd*�Ze		dSdTd.���Z
dUd/�ZdVd2�ZdWd6�ZdXd7�ZdYd8�ZdZd[d:�Zd\d=�Zd\d>�Zd]d@�Z	d^d_dE�Zd`dF�Z						dadbdO�ZdcdP�Zd	S)d�Retrya�Retry configuration.

    Each retry attempt will create a new Retry object with updated values, so
    they can be safely reused.

    Retries can be defined as a default for a pool:

    .. code-block:: python

        retries = Retry(connect=5, read=2, redirect=5)
        http = PoolManager(retries=retries)
        response = http.request("GET", "https://example.com/")

    Or per-request (which overrides the default for the pool):

    .. code-block:: python

        response = http.request("GET", "https://example.com/", retries=Retry(10))

    Retries can be disabled by passing ``False``:

    .. code-block:: python

        response = http.request("GET", "https://example.com/", retries=False)

    Errors will be wrapped in :class:`~urllib3.exceptions.MaxRetryError` unless
    retries are disabled, in which case the causing exception will be raised.

    :param int total:
        Total number of retries to allow. Takes precedence over other counts.

        Set to ``None`` to remove this constraint and fall back on other
        counts.

        Set to ``0`` to fail on the first retry.

        Set to ``False`` to disable and imply ``raise_on_redirect=False``.

    :param int connect:
        How many connection-related errors to retry on.

        These are errors raised before the request is sent to the remote server,
        which we assume has not triggered the server to process the request.

        Set to ``0`` to fail on the first retry of this type.

    :param int read:
        How many times to retry on read errors.

        These errors are raised after the request was sent to the server, so the
        request may have side-effects.

        Set to ``0`` to fail on the first retry of this type.

    :param int redirect:
        How many redirects to perform. Limit this to avoid infinite redirect
        loops.

        A redirect is a HTTP response with a status code 301, 302, 303, 307 or
        308.

        Set to ``0`` to fail on the first retry of this type.

        Set to ``False`` to disable and imply ``raise_on_redirect=False``.

    :param int status:
        How many times to retry on bad status codes.

        These are retries made on responses, where status code matches
        ``status_forcelist``.

        Set to ``0`` to fail on the first retry of this type.

    :param int other:
        How many times to retry on other errors.

        Other errors are errors that are not connect, read, redirect or status errors.
        These errors might be raised after the request was sent to the server, so the
        request might have side-effects.

        Set to ``0`` to fail on the first retry of this type.

        If ``total`` is not set, it's a good idea to set this to 0 to account
        for unexpected edge cases and avoid infinite retry loops.

    :param Collection allowed_methods:
        Set of uppercased HTTP method verbs that we should retry on.

        By default, we only retry on methods which are considered to be
        idempotent (multiple requests with the same parameters end with the
        same state). See :attr:`Retry.DEFAULT_ALLOWED_METHODS`.

        Set to a ``None`` value to retry on any verb.

    :param Collection status_forcelist:
        A set of integer HTTP status codes that we should force a retry on.
        A retry is initiated if the request method is in ``allowed_methods``
        and the response status code is in ``status_forcelist``.

        By default, this is disabled with ``None``.

    :param float backoff_factor:
        A backoff factor to apply between attempts after the second try
        (most errors are resolved immediately by a second try without a
        delay). urllib3 will sleep for::

            {backoff factor} * (2 ** ({number of previous retries}))

        seconds. If `backoff_jitter` is non-zero, this sleep is extended by::

            random.uniform(0, {backoff jitter})

        seconds. For example, if the backoff_factor is 0.1, then :func:`Retry.sleep` will
        sleep for [0.0s, 0.2s, 0.4s, 0.8s, ...] between retries. No backoff will ever
        be longer than `backoff_max`.

        By default, backoff is disabled (factor set to 0).

    :param bool raise_on_redirect: Whether, if the number of redirects is
        exhausted, to raise a MaxRetryError, or to return a response with a
        response code in the 3xx range.

    :param bool raise_on_status: Similar meaning to ``raise_on_redirect``:
        whether we should raise an exception, or return a response,
        if status falls in ``status_forcelist`` range and retries have
        been exhausted.

    :param tuple history: The history of the request encountered during
        each call to :meth:`~Retry.increment`. The list is in the order
        the requests occurred. Each list item is of class :class:`RequestHistory`.

    :param bool respect_retry_after_header:
        Whether to respect Retry-After header on status codes defined as
        :attr:`Retry.RETRY_AFTER_STATUS_CODES` or not.

    :param Collection remove_headers_on_redirect:
        Sequence of headers to remove from the request when a response
        indicating a redirect is returned before firing off the redirected
        request.
    )�HEAD�GET�PUT�DELETE�OPTIONS�TRACE)i�i�i��
Authorization�xztyping.ClassVar[Retry]�DEFAULT�
NrT��total�bool | int | None�connectr�read�redirectr�other�allowed_methods�typing.Collection[str] | None�status_forcelist�typing.Collection[int] | None�backoff_factor�float�backoff_max�raise_on_redirect�bool�raise_on_status�history�!tuple[RequestHistory, ...] | None�respect_retry_after_header�remove_headers_on_redirect�typing.Collection[str]�backoff_jitter�return�Nonec�L�||_||_||_||_||_|dus|durd}d}||_|p
t
��|_||_|	|_	|
|_
||_||_|
pd|_
||_td�|D����|_||_dS)NFrr c3�>K�|]}|���V��dS�N)�lower)�.0�hs  r"�	<genexpr>z!Retry.__init__.<locals>.<genexpr>�s;����4
�4
��A�G�G�I�I�4
�4
�4
�4
�4
�4
r!)r0r2r3rr5r4�setr8r6r:r<r=r?r@rB�	frozensetrCrE)�selfr0r2r3r4rr5r6r8r:r<r=r?r@rBrCrEs                 r"�__init__zRetry.__init__�s���*��
������	������
��u��������H� %�� ��
� 0� 9�C�E�E���.���,���&���!2���.����}�"���*D��'�*3�4
�4
�9�4
�4
�4
�+
�+
��'�-����r!�kw�
typing.Anyc�j�tdid|j�d|j�d|j�d|j�d|j�d|j�d|j�d|j�d	|j	�d
|j
�d|j�d|j�d
|j
�d|j�d|j�d|j��}|�|��t%|��di|��S)Nr0r2r3r4rr5r6r8r:r<r=r?r@rCrBrEr )�dictr0r2r3r4rr5r6r8r:r<r=r?r@rCrBrE�update�type)rQrS�paramss   r"�newz	Retry.new�s4���
�
�
��*�*�
��L�L�
����
��]�]�	
�
�;�;�
��*�*�

�!�0�0�
�"�2�2�
� �.�.�
��(�(�
�#�4�4�
�!�0�0�
��L�L�
�(,�'F�'F�
�(,�'F�'F�
�  �.�.�!
��&	�
�
�b�����t�D�z�z�#�#�F�#�#�#r!�retries�Retry | bool | int | None�defaultc���|�|�|n|j}t|t��r|St|��od}|||���}t�d||��|S)z3Backwards-compatibility for the old retries format.N)r4z!Converted retries value: %r -> %r)r-�
isinstancer$r>�log�debug)�clsr[r4r]�new_retriess     r"�from_intzRetry.from_int
sq���?�!(�!4�g�g�#�+�G��g�u�%�%�	��N���>�>�*�d���c�'�H�5�5�5���	�	�5�w��L�L�L��r!c
�^�tttd�t|j��������}|dkrdS|jd|dz
zz}|jdkr|tj��|jzz
}ttdt|j|������S)zIFormula for computing the current backoff

        :rtype: float
        c��|jduSrJ)r)�xs r"�<lambda>z(Retry.get_backoff_time.<locals>.<lambda>%s��A�$7�4�$?�r!rrrr/)�len�listr�reversedr@r:rE�randomr;�max�minr<)rQ�consecutive_errors_len�
backoff_values   r"�get_backoff_timezRetry.get_backoff_times���"%���?�?��$�,�AW�AW�X�X�
�
�"
�"
��
"�Q�&�&��1��+�q�5K�a�5O�/P�Q�
���#�%�%��V�]�_�_�t�/B�B�B�M��S��C�� 0�-�@�@�A�A�B�B�Br!�retry_after�strc�@�tjd|��rt|��}nhtj�|��}|�t
d|�����tj�|��}|tj��z
}t|d��}|S)Nz^\s*[0-9]+\s*$zInvalid Retry-After header: r)
�re�match�int�email�utils�parsedate_tzr�	mktime_tz�timerm)rQrr�seconds�retry_date_tuple�
retry_dates     r"�parse_retry_afterzRetry.parse_retry_after0s����8�%�{�3�3�	/��+�&�&�G�G�$�{�7�7��D�D���'�#�$P�;�$P�$P�Q�Q�Q���.�.�/?�@�@�J� �4�9�;�;�.�G��g�q�/�/���r!�responser�float | Nonec�h�|j�d��}|�dS|�|��S)z(Get the value of Retry-After in seconds.zRetry-AfterN)�headers�getr��rQr�rrs   r"�get_retry_afterzRetry.get_retry_afterAs9���&�*�*�=�9�9�����4��%�%�k�2�2�2r!c�`�|�|��}|rtj|��dSdS)NTF)r�r|�sleepr�s   r"�sleep_for_retryzRetry.sleep_for_retryKs7���*�*�8�4�4���	��J�{�#�#�#��4��ur!c�f�|���}|dkrdStj|��dS)Nr)rqr|r�)rQ�backoffs  r"�_sleep_backoffzRetry._sleep_backoffSs7���'�'�)�)���a�<�<��F��
�7�����r!�BaseHTTPResponse | Nonec�r�|jr|r|�|��}|rdS|���dS)aBSleep between retry attempts.

        This method will respect a server's ``Retry-After`` response header
        and sleep the duration of the time requested. If that is not present, it
        will use an exponential backoff. By default, the backoff factor is 0 and
        this method will return immediately.
        N)rBr�r�)rQr��slepts   r"r�zRetry.sleepYsN���*�	�x�	��(�(��2�2�E��
����������r!�err�	Exceptionc�d�t|t��r|j}t|t��S)zzErrors when we're fairly sure that the server did not receive the
        request, so it should be safe to retry.
        )r_r�original_errorr�rQr�s  r"�_is_connection_errorzRetry._is_connection_erroris/���c�:�&�&�	%��$�C��#�2�3�3�3r!c�:�t|ttf��S)zErrors that occur after the request has been started, so we should
        assume that the server began processing it.
        )r_rr
r�s  r"�_is_read_errorzRetry._is_read_errorqs���#� 0�-�@�A�A�Ar!rc�N�|jr|���|jvrdSdS)zyChecks if a given HTTP method should be retried upon, depending if
        it is included in the allowed_methods
        FT)r6�upper)rQrs  r"�_is_method_retryablezRetry._is_method_retryablews.����	�F�L�L�N�N�$�:N�$N�$N��5��tr!F�status_coderw�has_retry_afterc��|�|��sdS|jr||jvrdSt|jo|jo
|o||jv��S)awIs this method/status code retryable? (Based on allowlists and control
        variables such as the number of total retries to allow, whether to
        respect the Retry-After header, whether this header is present, and
        whether the returned status code is on the list of status codes to
        be retried upon on the presence of the aforementioned header)
        FT)r�r8r>r0rB�RETRY_AFTER_STATUS_CODES)rQrr�r�s    r"�is_retryzRetry.is_retrysx���(�(��0�0�	��5�� �	�[�D�4I�%I�%I��4���J�
?��/�
?��
?��� =�=�	
�
�	
r!c��d�|j|j|j|j|j|jfD��}|sdSt
|��dkS)zAre we out of retries?c��g|]}|�|��Sr r )rLrgs  r"�
<listcomp>z&Retry.is_exhausted.<locals>.<listcomp>�s0��
�
�
���
�
�
�
�
r!Fr)r0r2r3r4rr5rn)rQ�retry_countss  r"�is_exhaustedzRetry.is_exhausted�sd��
�
��
����	��
����
�
�
�
�
���	��5��<� � �1�$�$r!rrrr�_pool�ConnectionPool | None�_stacktrace�TracebackType | Nonec	�0�|jdur |rtt|��||���|j}|�|dz}|j}|j}	|j}
|j}|j}d}
d}d}|r?|�|��r*|durtt|��||���|�|dz}n�|rV|�	|��rA|	dus|�|�
|��stt|��||���|	�|	dz}	n�|r|�|dz}n�|r=|���r)|
�|
dz}
d}
|���}|r|}|j}nHtj
}
|r:|jr3|�|dz}tj�|j���}
|j}|jt#|||||��fz}|�|||	|
|||���}|���r#|pt|
��}t)|||��|�t*�d||��|S)	a�Return a new Retry object with incremented retry counters.

        :param response: A response object, or None, if the server did not
            return a response.
        :type response: :class:`~urllib3.response.BaseHTTPResponse`
        :param Exception error: An error encountered during the request, or
            None if the response was received successfully.

        :return: A new ``Retry`` object.
        FNr�unknownztoo many redirects)r�)r0r2r3r4rr5r@z$Incremented Retry for (url='%s'): %r)r0rrXr2r3r4rr5r�r�r��get_redirect_locationr
�
GENERIC_ERROR�SPECIFIC_ERROR�formatr@rrZr�r	r`ra)rQrrr�rr�r�r0r2r3r4�status_countr5�causerr�response_redirect_locationr@�	new_retry�reasons                    r"�	incrementzRetry.increment�s���&�:����5���$�u�+�+�u�k�:�:�:��
�����Q�J�E��,���y���=���{���
������ ���%	)�T�.�.�u�5�5�%	)��%����d�5�k�k�5�+�>�>�>��$��1����
�	)�t�*�*�5�1�1�	)��u�}�}���d�6O�6O�PV�6W�6W���d�5�k�k�5�+�>�>�>��!���	���
�	)�� ���
���
�	)�(�8�8�:�:�	)��#��A�
��(�E�)1�)G�)G�)I�)I�&�)�
?�$>�!��_�F�F�
"�/�E��
)�H�O�
)��+� �A�%�L�%�4�;�;���;�X�X��!����,��6�3��v�7H�I�I�"
�
���H�H���������
�
�	��!�!�#�#�	@��2�m�E�2�2�F���s�F�3�3��?��	�	�8�#�y�I�I�I��r!c��t|��j�d|j�d|j�d|j�d|j�d|j�d�S)Nz(total=z
, connect=z, read=z, redirect=z	, status=�))rXrr0r2r3r4r)rQs r"�__repr__zRetry.__repr__	sx���D�z�z�"�
Q�
Q�4�:�
Q�
Q���
Q�
Q��I�
Q�
Q�*.�-�
Q�
Q�BF�+�
Q�
Q�
Q�	
r!)"r0r1r2rr3rr4r1rrr5rr6r7r8r9r:r;r<r;r=r>r?r>r@rArBr>rCrDrEr;rFrG)rSrTrFr$)TN)r[r\r4r1r]r\rFr$)rFr;)rrrsrFr;)r�rrFr�)r�rrFr>)rFrGrJ)r�r�rFrG)r�r�rFr>)rrsrFr>)F)rrsr�rwr�r>rFr>)rFr>)NNNNNN)rrrrr�r�rrr�r�r�r�rFr$)rFrs)rrr�__doc__rP�DEFAULT_ALLOWED_METHODSr��"DEFAULT_REMOVE_HEADERS_ON_REDIRECT�DEFAULT_BACKOFF_MAXrrRrZ�classmethodrdrqr�r�r�r�r�r�r�r�r�r�r�r�r r!r"r$r$'sL�������K�K�\(�i�<�<�<����
 )�y����9�9��*3��O�3D�)E�)E�&���$�#�#�#�$&�"��&*�!� �9P�:>� !�0�"&� $�59�+/�
/� #�'+-�+-�+-�+-�+-�Z$�$�$�$�.�'+�-1�	�����[��$C�C�C�C�&����"3�3�3�3�������������� 4�4�4�4�B�B�B�B�����FK�
�
�
�
�
�,%�%�%�%�*"��,0�"&�'+�,0�_�_�_�_�_�B
�
�
�
�
�
r!r$�)"�
__future__rrx�loggingrlrur|�typing�	itertoolsr�typesr�
exceptionsrrr	r
rrr
�utilr�
TYPE_CHECKING�connectionpoolrr�r�	getLoggerrr`�
NamedTuplerr$r-r r!r"�<module>r�s���"�"�"�"�"�"���������
�
�
�
�	�	�	�	�����
�
�
�
�������������������������������������	��,�/�/�/�/�/�/�+�+�+�+�+�+��g���!�!��"�"�"�"�"�V�&�"�"�"�f
�f
�f
�f
�f
�f
�f
�f
�T��a����
�
�
r!

Hacked By AnonymousFox1.0, Coded By AnonymousFox