Source code for httk.core.datastream.network_policy

"""Policy and timeout helpers for network-backed datastream opens."""

DEFAULT_NETWORK_TIMEOUT: float | None = 30.0
"""Default timeout for each network open; read freshly for every open, or ``None`` to disable."""

NETWORK_SCHEMES = frozenset({"http", "https", "ftp"})
"""Schemes treated as network access; ``file`` is local I/O and deliberately absent."""






[docs] def resolve_timeout(hint: float | None) -> float | None: """Return an explicit timeout or the current module default. :param hint: Explicit timeout, or ``None`` to use the module default. :return: The timeout to pass to the network opener. """ return hint if hint is not None else DEFAULT_NETWORK_TIMEOUT