Back to Fastmcp

timeout

docs/python-sdk/fastmcp-utilities-timeout.mdx

3.2.41.2 KB
Original Source

fastmcp.utilities.timeout

Timeout normalization utilities.

Functions

normalize_timeout_to_timedelta <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/utilities/timeout.py#L8" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
normalize_timeout_to_timedelta(value: int | float | datetime.timedelta | None) -> datetime.timedelta | None

Normalize a timeout value to a timedelta.

Args:

  • value: Timeout value as int/float (seconds), timedelta, or None

Returns:

  • timedelta if value provided, None otherwise

normalize_timeout_to_seconds <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/utilities/timeout.py#L28" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
normalize_timeout_to_seconds(value: int | float | datetime.timedelta | None) -> float | None

Normalize a timeout value to seconds (float).

Args:

  • value: Timeout value as int/float (seconds), timedelta, or None. Zero values are treated as "disabled" and return None.

Returns:

  • float seconds if value provided and non-zero, None otherwise