ok

Mini Shell

Direktori : /opt/imunify360/venv/lib/python3.11/site-packages/urllib3/util/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib/python3.11/site-packages/urllib3/util/__pycache__/timeout.cpython-311.pyc

�

m��f'���ddlmZddlZddlmZddlmZe��Ze	edej��Z
Gd�de��ZdS)	�)�absolute_importN)�_GLOBAL_DEFAULT_TIMEOUT�)�TimeoutStateError�	monotonicc��eZdZdZeZdeefd�Zd�ZeZ	e
d���Ze
d���Zd�Z
d�Zd	�Zed
���Zed���ZdS)�Timeouta2Timeout configuration.

    Timeouts can be defined as a default for a pool:

    .. code-block:: python

       timeout = Timeout(connect=2.0, read=7.0)
       http = PoolManager(timeout=timeout)
       response = http.request('GET', 'http://example.com/')

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

    .. code-block:: python

       response = http.request('GET', 'http://example.com/', timeout=Timeout(10))

    Timeouts can be disabled by setting all the parameters to ``None``:

    .. code-block:: python

       no_timeout = Timeout(connect=None, read=None)
       response = http.request('GET', 'http://example.com/, timeout=no_timeout)


    :param total:
        This combines the connect and read timeouts into one; the read timeout
        will be set to the time leftover from the connect attempt. In the
        event that both a connect timeout and a total are specified, or a read
        timeout and a total are specified, the shorter timeout will be applied.

        Defaults to None.

    :type total: int, float, or None

    :param connect:
        The maximum amount of time (in seconds) to wait for a connection
        attempt to a server to succeed. Omitting the parameter will default the
        connect timeout to the system default, probably `the global default
        timeout in socket.py
        <http://hg.python.org/cpython/file/603b4d593758/Lib/socket.py#l535>`_.
        None will set an infinite timeout for connection attempts.

    :type connect: int, float, or None

    :param read:
        The maximum amount of time (in seconds) to wait between consecutive
        read operations for a response from the server. Omitting the parameter
        will default the read timeout to the system default, probably `the
        global default timeout in socket.py
        <http://hg.python.org/cpython/file/603b4d593758/Lib/socket.py#l535>`_.
        None will set an infinite timeout.

    :type read: int, float, or None

    .. note::

        Many factors can affect the total amount of time for urllib3 to return
        an HTTP response.

        For example, Python's DNS resolver does not obey the timeout specified
        on the socket. Other factors that can affect total request time include
        high CPU load, high swap, the program running at a low priority level,
        or other behaviors.

        In addition, the read and total timeouts only measure the time between
        read operations on the socket connecting the client and the server,
        not the total amount of time for the request to return a complete
        response. For most requests, the timeout is raised because the server
        has not sent the first byte in the specified time. This is not always
        the case; if a server streams one byte every fifteen seconds, a timeout
        of 20 seconds will not trigger, even though the request will take
        several minutes to complete.

        If your goal is to cut off any request after a set amount of wall clock
        time, consider having a second "watcher" thread to cut off a slow
        request.
    Nc��|�|d��|_|�|d��|_|�|d��|_d|_dS)N�connect�read�total)�_validate_timeout�_connect�_readr
�_start_connect)�selfr
rrs    �K/opt/imunify360/venv/lib64/python3.11/site-packages/urllib3/util/timeout.py�__init__zTimeout.__init__fsU���.�.�w�	�B�B��
��+�+�D�&�9�9��
��+�+�E�7�;�;��
�"�����c�`�t|��j�d|j�d|j�d|j�d�S)Nz	(connect=z, read=z, total=�))�type�__name__rrr
�rs r�__repr__zTimeout.__repr__ls9����J�J�����M�M�M��J�J�J��J�J�J�	
�	
rc��|tur|jS|�	||jur|St|t��rt	d���	t|��n+#ttf$rt	d|�d|�d����wxYw	|dkrt	d|�d|�d	����n$#t$rt	d|�d|�d����wxYw|S)
a�Check that a timeout attribute is valid.

        :param value: The timeout value to validate
        :param name: The name of the timeout attribute to validate. This is
            used to specify in error messages.
        :return: The validated and casted version of the given value.
        :raises ValueError: If it is a numeric value less than or equal to
            zero, or the type is not an integer, float, or None.
        NzDTimeout cannot be a boolean value. It must be an int, float or None.zTimeout value z was z', but it must be an int, float or None.rzAttempted to set z timeout to zC, but the timeout cannot be set to a value less than or equal to 0.)�_Default�DEFAULT_TIMEOUT�
isinstance�bool�
ValueError�float�	TypeError)�cls�value�names   rrzTimeout._validate_timeoutws5���H����&�&��=�E�S�%8�8�8��L��e�T�"�"�	��,���
�	��%�L�L�L�L���:�&�	�	�	��*�)-���u�u�u�6���
�	����	���z�z� �j�.2�T�T�5�5�5�:�������	�	�	��*�)-���u�u�u�6���
�	�����s�A�(A;�?B�!B=c�$�t||���S)a�Create a new Timeout from a legacy timeout value.

        The timeout value used by httplib.py sets the same timeout on the
        connect(), and recv() socket requests. This creates a :class:`Timeout`
        object that sets the individual timeouts to the ``timeout`` value
        passed to this function.

        :param timeout: The legacy timeout value.
        :type timeout: integer, float, sentinel default object, or None
        :return: Timeout object
        :rtype: :class:`Timeout`
        )rr)r	)r$�timeouts  r�
from_floatzTimeout.from_float�s���G�W�5�5�5�5rc�D�t|j|j|j���S)aCreate a copy of the timeout object

        Timeout properties are stored per-pool but each request needs a fresh
        Timeout object to ensure each one has its own start/stop configured.

        :return: a copy of the timeout object
        :rtype: :class:`Timeout`
        )rrr
)r	rrr
rs r�clonez
Timeout.clone�s���t�}�4�:�T�Z�P�P�P�Prc�b�|j�td���t��|_|jS)z�Start the timeout clock, used during a connect() attempt

        :raises urllib3.exceptions.TimeoutStateError: if you attempt
            to start a timer that has been started already.
        Nz'Timeout timer has already been started.�rr�current_timers r�
start_connectzTimeout.start_connect�s1����*�#�$M�N�N�N�*�n�n����"�"rc�Z�|j�td���t��|jz
S)aGets the time elapsed since the call to :meth:`start_connect`.

        :return: Elapsed time in seconds.
        :rtype: float
        :raises urllib3.exceptions.TimeoutStateError: if you attempt
            to get duration for a timer that hasn't been started.
        Nz:Can't get connect duration for timer that has not started.r-rs r�get_connect_durationzTimeout.get_connect_duration�s6����&�#�L���
��~�~�� 3�3�3rc��|j�|jS|j�|j|jur|jSt|j|j��S)a!Get the value to use when setting a connection timeout.

        This will be a positive float or integer, the value None
        (never timeout), or the default system timeout.

        :return: Connect timeout.
        :rtype: int, float, :attr:`Timeout.DEFAULT_TIMEOUT` or None
        )r
rr�minrs r�connect_timeoutzTimeout.connect_timeout�sG���:���=� ��=� �D�M�T�5I�$I�$I��:���4�=�$�*�-�-�-rc�x�|j�n|j|jur`|j�Y|j|jurK|j�|jSt	dt|j|���z
|j����S|j�8|j|jur*t	d|j|���z
��S|jS)a�Get the value for the read timeout.

        This assumes some time has elapsed in the connection timeout and
        computes the read timeout appropriately.

        If self.total is set, the read timeout is dependent on the amount of
        time taken by the connect timeout. If the connection time has not been
        established, a :exc:`~urllib3.exceptions.TimeoutStateError` will be
        raised.

        :return: Value to use for the read timeout.
        :rtype: int, float, :attr:`Timeout.DEFAULT_TIMEOUT` or None
        :raises urllib3.exceptions.TimeoutStateError: If :meth:`start_connect`
            has not yet been called on this object.
        Nr)r
rrr�maxr3r1rs r�read_timeoutzTimeout.read_timeout�s���$
�J�"��
�$�"6�6�6��
�&��
�$�"6�6�6��"�*��z�!��q�#�d�j�4�+D�+D�+F�+F�F��
�S�S�T�T�T�
�Z�
#��
�$�:N�(N�(N��q�$�*�t�'@�'@�'B�'B�B�C�C�C��:�r)r�
__module__�__qualname__�__doc__rrrrr�__str__�classmethodrr)r+r/r1�propertyr4r7�rrr	r	s�������L�L�^.�O�!�8�(�#�#�#�#�
�
�
��G��+�+��[�+�Z�
6�
6��[�
6�Q�Q�Q�	#�	#�	#�4�4�4��.�.��X�.�"����X���rr	)�
__future__r�time�socketr�
exceptionsr�objectr�getattrr.r	r>rr�<module>rEs���&�&�&�&�&�&�����+�*�*�*�*�*�*�*�*�*�*�*��6�8�8���w�t�[�$�)�4�4��x�x�x�x�x�f�x�x�x�x�xr

Zerion Mini Shell 1.0