Restart
RestartSpec
dataclass
Specification for how a Service should handle restarts and budget exhaustion.
Attach to a :class:Service subclass as a class attribute::
class MyService(Service):
restart_spec = RestartSpec(restart_type=RestartType.PERMANENT)
Source code in src/hassette/resources/restart.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
restart_type: RestartType = RestartType.TRANSIENT
class-attribute
instance-attribute
Strategy governing restart and budget-exhaustion behavior.
non_retryable_error_names: tuple[str, ...] = ()
class-attribute
instance-attribute
Exception type names that skip restart and follow the budget-exhaustion path directly.
fatal_error_names: tuple[str, ...] = ()
class-attribute
instance-attribute
Exception type names that always trigger immediate shutdown regardless of restart_type.
backoff_base_seconds: float = 2.0
class-attribute
instance-attribute
Base seconds for exponential backoff between restart attempts.
backoff_multiplier: float = 2.0
class-attribute
instance-attribute
Multiplier applied to backoff on each successive restart attempt.
backoff_max_seconds: float = 60.0
class-attribute
instance-attribute
Maximum backoff delay in seconds.
budget_intensity: int = 5
class-attribute
instance-attribute
Maximum number of restarts allowed within the budget window.
budget_period_seconds: float = 300.0
class-attribute
instance-attribute
Sliding window size in seconds for the restart budget.
startup_timeout_seconds: float = 30.0
class-attribute
instance-attribute
How long to wait for mark_ready() after a restart before considering it failed.
cooldown_seconds: float = 300.0
class-attribute
instance-attribute
Duration in seconds for the long-cooldown phase (TRANSIENT services only).
max_cooldown_cycles: int = 0
class-attribute
instance-attribute
Maximum cooldown cycles before transitioning to EXHAUSTED_DEAD. 0 = infinite.