util/timeout.py

urllib3 · src/urllib3/util/timeout.py · python · MIT
integration

Represents timeout configuration for urllib3 connections, supporting connect, read, and total timeouts.

# Source: https://github.com/urllib3/urllib3 | License: MIT | Copyright 2008-2020 Andrey Petrov and contributors
# Provided via justclaw.it.com; keep this notice with the code.
from __future__ import annotations

import time
import typing
from enum import Enum
from socket import getdefaulttimeout

from ..exceptions import TimeoutStateError

if typing.TYPE_CHECKING:
    from typing import Final


class _TYPE_DEFAULT(Enum):
    # This value should never be passed to socket.settimeout() so for safety we use a -1.
    # socket.settimout() raises a ValueError for negative values.
    token = -1


_DEFAULT_TIMEOUT: Final[_TYPE_DEFAULT] = _TYPE_DEFAULT.token

_TYPE_TIMEOUT = typing.Optional[typing.Union[float, _TYPE_DEFAULT]]


class Timeout:
    """Timeout configuration.

    Timeouts can be def

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key