Built-in Exceptions

TimeoutError — exception class

An operation timed out at the system level. Distinguish elapsed deadlines from successful completion; use bounded retry and account for possible side effects. asyncio.TimeoutError is an alias of this class in Python 3.11 and later. The example uses the symbolic errno.ETIMEDOUT to demonstrate CPython exception selection without accessing an external system. The example raises a controlled stand-in to demonstrate handling; it does not cause the real system failure. Catch TimeoutError when this category is the recovery boundary; do not rely on the exact human-readable message.

Formal Syntax & Structure

python syntaxpython
TimeoutError

Return Value

type

The class object TimeoutError; this reference documents the class identity, not a universal constructor signature.

Working Example

Example Snippetpython
import errnotry:    raise OSError(errno.ETIMEDOUT,"demo")except TimeoutError as error:    print(type(error).__name__)
Python Reference