Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in the ability to start timers paused. #1138

Merged
merged 3 commits into from
Jul 5, 2023

Conversation

clalancette
Copy link
Contributor

This was possible in the past by creating a timer
and then immediately canceling it. But that could lead to a potential race where the timer fired once before it was canceled. By allowing for the user
to create it paused, we avoid that race.

This is the rclpy version of ros2/rclcpp#2005

@Voldivh @fujitatomoya FYI. This fixes #1137

This was possible in the past by creating a timer
and then immediately canceling it.  But that could
lead to a potential race where the timer fired once
before it was canceled.  By allowing for the user
to create it paused, we avoid that race.

This is the rclpy version of ros2/rclcpp#2005

Signed-off-by: Chris Lalancette <[email protected]>
rclpy/rclpy/node.py Outdated Show resolved Hide resolved
rclpy/rclpy/timer.py Show resolved Hide resolved
rclpy/test/test_waitable.py Show resolved Hide resolved
Signed-off-by: Chris Lalancette <[email protected]>
Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍

maybe we could add doc section that says timer with autostart = false can be started with calling reset method.

Signed-off-by: Chris Lalancette <[email protected]>
@clalancette
Copy link
Contributor Author

maybe we could add doc section that says timer with autostart = false can be started with calling reset method.

Excellent point. I've added documentation in fa71994.

@clalancette
Copy link
Contributor Author

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@clalancette clalancette merged commit 542259d into rolling Jul 5, 2023
@clalancette clalancette deleted the clalancette/paused-by-default-timer branch July 5, 2023 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add autostart timer option for the Timer class
3 participants