launch.actions.timer_action module
Module for the TimerAction action.
- class launch.actions.timer_action.TimerAction[source]
Bases:
Action
Action that defers other entities until a period of time has passed, unless canceled.
All timers are “one-shot”, in that they only fire one time and never again.
- __init__(*, period: float | str | Substitution | Iterable[str | Substitution], actions: Iterable[LaunchDescriptionEntity], cancel_on_shutdown: bool | str | Substitution | Iterable[str | Substitution] = True, **kwargs) None [source]
Create a TimerAction.
- Parameters:
period – the time (in seconds) to set the timer for
actions – an iterable containing actions to be executed on timeout
cancel_on_shutdown – whether to cancel the timer on launch shutdown
- property actions
- cancel() None [source]
Cancel this TimerAction.
Calling cancel will not fail if the timer has already finished or already been canceled or if the timer has not been started yet.
This function is not thread-safe and should be called only from under another coroutine.
- describe_conditional_sub_entities() List[Tuple[str, Iterable[LaunchDescriptionEntity]]] [source]
Return the actions that will result when the timer expires, but was not canceled.
- execute(context: LaunchContext) List[LaunchDescriptionEntity] | None [source]
Execute the action.
This does the following: - register a global event handler for TimerAction’s if not already done - create a task for the coroutine that waits until canceled or timeout - coroutine asynchronously fires event after timeout, if not canceled
- get_asyncio_future() Future | None [source]
Return an asyncio Future, used to let the launch system know when we’re done.
- handle(context: LaunchContext) LaunchDescriptionEntity | Iterable[LaunchDescriptionEntity] | None [source]
Handle firing of timer.
- classmethod parse(entity: Entity, parser: Parser)[source]
Return the Timer action and kwargs for constructing it.
- property period