-
Notifications
You must be signed in to change notification settings - Fork 227
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 an optional timeout_sec input to Client.call() to fix issue https://github.com/ros2/rclpy/issues/1181 #1188
Conversation
Signed-off-by: KKSTB <[email protected]>
Signed-off-by: KKSTB <[email protected]>
Signed-off-by: KKSTB <[email protected]>
Signed-off-by: KKSTB <[email protected]>
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.
IMO, we could deprecate those sync APIs like this as rclpy
, because rclpy
provides async APIs and user can manage from there, including these timeout behavior as they like.
On the other hand, I see this is one of the enhancements, at lease at this moment.
any thoughts?
No idea too. I think it depends on how rclpy in ROS2 is positioned:
|
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 with one nit addressed
address #1181 |
@KKSTB can you add the test for timeout case to https://github.com/ros2/rclpy/blob/rolling/rclpy/test/test_client.py, then i will start the CI. |
This is a bit difficult now as I cannot build rclpy successfully due to recent change in rcl_node_type_description_service_init() ros2/rcl@1b79535 Have to wait for rolling update. |
@KKSTB i am not sure what you mean but you are doing the source build? https://docs.ros.org/en/rolling/Installation/Alternatives/Ubuntu-Development-Setup.html#build-ros-2, this is what we do for the mainline rolling development. |
Signed-off-by: KKSTB <[email protected]>
@fujitatomoya thanks. Although it takes a long time to build from source. I was originally using binary install of rolling, therefore failed to build. |
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.
overall lgtm, several comments to discuss.
2. Remove test_sync_call_slow() 3. Shorten test time Signed-off-by: KKSTB <[email protected]>
@ros-pull-request-builder retest this please |
The Rpr jobs aren't going to succeed here until we do releases of |
Signed-off-by: KKSTB <[email protected]>
Yet another flake8 and fixed |
I was just about to implement this and saw that it's already on rolling, can this be backported to humble please? |
…1181 (ros2#1188) Signed-off-by: KKSTB <[email protected]>
Additionally a comment about the PR. It's surprising to me that you went with returning None if the call timed out instead of raising an Exception. Just returning None increases the risk of "silent bugs", especially for services not expecting a response. |
@tonynajjar @KKSTB can you review #1271? i think it makes more sense to raise |
@tonynajjar i am not inclined to do that. #1188 (review), probably we eventually deprecate this method in the future... @clalancette @sloretz @adityapande-1995 @wjwwood what do you think? |
We can't change a stable function in Humble to suddenly be able to throw an exception (or return None). You could consider a rewrite of this feature as a separate function, so it's purely new API. But even then we have to be careful that we don't accidentally change the behavior of existing functions either intentionally or as a new bug. That's why we're generally not inclined to back port features to older versions. |
Thanks @tonynajjar. You are right that returning None increases the chance of silent bug. What I considered at that time was to return whatever As for backporting to older version, I also hope this to happen in ROS Iron which I am using. But I go with the way similar to what @wjwwood suggest so that the fix (or any other customization or convenient wrappers) becomes readily available in my version of ROS Iron:
Its just my personal suggestion as a ROS user, and not representing what ROS team is suggesting. Hope that help. |
Add an optional timeout_sec input so that the
call()
function can break away from the deadlock if RMW fails to response. Thecall()
function returns future.result() which isNone
.Another approach of adding timeout to the future returned by
call_async()
is much more difficult to implement, requiring changes from theFuture
class and upward. Also there is no timeout input for the rclcpp version ofasync_send_request()
. So I would prefer not taking this approach instead.