Skip to content

Added timeout_sec_to_nsec utility#160

Merged
sloretz merged 2 commits intomasterfrom
add_timeout_utility
Nov 29, 2017
Merged

Added timeout_sec_to_nsec utility#160
sloretz merged 2 commits intomasterfrom
add_timeout_utility

Conversation

@sloretz
Copy link
Copy Markdown
Contributor

@sloretz sloretz commented Nov 28, 2017

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

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

Executor timeouts now block if None or Negative
Executor is only non-blocking if timeout is zero
@sloretz sloretz added the in review Waiting for review (Kanban column) label Nov 28, 2017
@sloretz sloretz self-assigned this Nov 28, 2017
Copy link
Copy Markdown
Member

@mikaelarguedas mikaelarguedas left a 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
Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍 works for me

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))
Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@sloretz
Copy link
Copy Markdown
Contributor Author

sloretz commented Nov 29, 2017

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.

@sloretz sloretz merged commit df26570 into master Nov 29, 2017
@sloretz sloretz deleted the add_timeout_utility branch November 29, 2017 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in review Waiting for review (Kanban column)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants