-
Notifications
You must be signed in to change notification settings - Fork 237
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
Added timeout_sec_to_nsec utility #160
Conversation
Executor timeouts now block if None or Negative Executor is only non-blocking if timeout is zero
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, 2 nitpicks that are not preventing this from getting merged
Python tends to use floating point numbers in seconds for timeouts. This utility converts a | ||
python-style timeout to an integer in nanoseconds that can be used by rcl_wait. | ||
|
||
:param timeout_sec: Seconds to wait. Block forever if None or negative. Don't wait if < 1ns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Don't wait if 0 <= timeout_sec < 1ns
maybe it's clear enough as is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is okay with you, I would like to leave this as is to avoid wrapping the line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 works for me
rclpy/test/test_utilities.py
Outdated
self.assertGreater(0, rclpy.utilities.timeout_sec_to_nsec(None)) | ||
self.assertGreater(0, rclpy.utilities.timeout_sec_to_nsec(-1)) | ||
self.assertEqual(0, rclpy.utilities.timeout_sec_to_nsec(0)) | ||
self.assertEqual(int(1.5 * S_TO_NS), rclpy.utilities.timeout_sec_to_nsec(1.5)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: should we add a test to show that something < 1ns results in a timeout of 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OSX job failed because the node died. Jenkins auto-retriggered it and the second build succeeded: http://ci.ros2.org/job/ci_osx/2965/. I think this can be merged. |
Taken from #140 / #127. It adds a utility for converting timeouts from seconds to nanoseconds for rcl_wait. Additionally executor timeouts now block if None or negative and are only non-blocking if the timeout is zero.
CI