maple.utils.timeout

Timeout utilities for MAPLE operations.

This module provides timeout handling for policy inference and environment operations. It wraps operations with configurable timeouts and provides graceful failure handling.

Key features: - Configurable timeouts for different operation types - Thread-based timeout implementation (cross-platform) - Graceful error messages for timeout failures - Context manager for timeout blocks

Classes

OperationTimer(operation[, expected, ...])

Timer for tracking operation duration and detecting slow operations.

TimeoutConfig([policy_act, env_setup, ...])

Configuration for operation timeouts.

TimeoutContext(timeout[, operation])

Context manager for timeout blocks.

Functions

check_container_responsive(check_fn[, ...])

Check if a container is responsive within timeout.

run_with_timeout(func, timeout[, operation, ...])

Run a function with a timeout.

with_timeout(timeout[, operation])

Decorator to add timeout to a function.

Exceptions

TimeoutError(operation, timeout[, message])

Raised when an operation times out.