timeout

Signature

faultcore.timeout(*, connect: str | None = None, recv: str | None = None)

Purpose

Sets connect and/or receive timeout behavior for operations executed inside the decorated function.

Parameters

  • connect: duration in ms or s.

  • recv: duration in ms or s.

Defaults and validation

  • Both parameters are optional.

  • Duration must be non-negative and use suffix (ms or s).

Unit test example (pytest)

import faultcore
import pytest


def test_http_client_timeout_path() -> None:
    @faultcore.timeout(connect="250ms", recv="900ms")
    def call() -> str:
        raise TimeoutError("simulated")

    with pytest.raises(TimeoutError):
        call()

Integration example (real network path)

Common errors

  • Missing unit suffix ("250" instead of "250ms").

  • Empty duration values.