step.timeout_dsl¶
Auto-generated step builders and DSL functions — DO NOT EDIT.
Source: timeout.py
Classes¶
Builder for Timeout. Auto-generated — do not edit. |
Functions¶
|
Wrap a step with a time limit, cancelling it if it runs too long. |
Module Contents¶
- class step.timeout_dsl.TimeoutBuilder¶
Bases:
raccoon.step.step_builder.StepBuilderBuilder for Timeout. Auto-generated — do not edit.
- step(value: step.Step)¶
- step.timeout_dsl.timeout(step: step.Step = _UNSET, seconds: float | int = _UNSET, propagate: bool = False)¶
Wrap a step with a time limit, cancelling it if it runs too long.
Executes the given step normally but enforces a maximum wall-clock duration. If the wrapped step completes within the budget, the timeout step finishes successfully. If the step exceeds the time limit, it is cancelled via
asyncio.wait_forand an error is logged.By default (
propagate=False) an expired timeout is contained: it cancels only the wrapped step and then finishes successfully, so the surrounding sequence and every remaining mission keep running. This is what you almost always want on a robot — one stuckmotor_move_toshould not take down the whole run.Set
propagate=Trueto instead re-raiseTimeoutErrorafter cancelling the wrapped step. That aborts the enclosing sequence/mission and is only appropriate when the wrapped step is a hard prerequisite for everything that follows.Note that the wrapped step is always cancelled on timeout (its
finallyblocks run, so aMotionStepstill hard-stops the motors);propagateonly controls whether the timeout itself is treated as a failure of the enclosing mission. Any other exception raised by the wrapped step propagates normally regardless ofpropagate.This is especially useful around blocking steps like
motor_move_toorwait_for_buttonthat could stall indefinitely if the hardware misbehaves.- Parameters:
step – The step to execute under a time constraint. Must be a valid
Step(orStepProtocol) instance.seconds – Maximum allowed execution time in seconds. Must be positive.
propagate – When
False(default), a timeout cancels only the wrapped step and the mission continues. WhenTrue, theTimeoutErroris re-raised after cancellation, aborting the enclosing sequence/mission.
- Returns:
A TimeoutBuilder (chainable via
.step(),.seconds(),.propagate(),.on_anomaly(),.skip_timing()).
Example:
from raccoon.step import timeout from raccoon.step.motor import motor_move_to # Give the arm 5 seconds to reach position 300; cancel if stuck, # then carry on with the rest of the mission. timeout( motor_move_to(robot.motor(2), position=300, velocity=800), seconds=5.0, ) # Hard prerequisite: abort the mission if the button isn't pressed timeout(wait_for_button(), seconds=30.0, propagate=True)