-
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 optional timeout to client.call() #873
Add optional timeout to client.call() #873
Conversation
Signed-off-by: MuhongGuo <[email protected]>
5881c44
to
93b2c97
Compare
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.
although this makes sense to me, i would reconsider this synchronous method is really needed. probably we can just delete and supports only async method? so that application can avoid possible deadlock and can have all management in the application? (rclcpp does not have sync method for service client though.)
Yeah, preferably we would deprecate and remove |
@fujitatomoya @clalancette I believe most of the users are actually calling the services in a sync manner, blocking until the future is done. They will love the |
i do not have any data that shows how many user application use sync manner...it just depends on use case and application.
sounds good to me, although i do not have concrete idea to fix it right away... anyway, i think having timeout with current sync API makes sense for now. |
Unfortunately, in the default case (using a single threaded executor and the default callback group) this causes a deadlock. Even if you use separate callback groups and a multi-threaded executor, this is a bad idea; it is holding up the executor during the callback. That means that any subsequent callbacks in the callback group will be held up until the callback completes. In general, callbacks in ROS 2 should be as short as possible so as to minimize latency for all callbacks.
The deadlock is called by the fact that subscription callbacks occur on a thread, but service calls need to use that very same executor to get the response. Using the multi-threaded executor doesn't help either, because by default all callbacks are in the default callback group, and it is non-reentrant (which means only one of the members of the callback group can be running at a time). Because of the design if this, we haven't found a way to make this work better (though if you have ideas, we are certainly willing to consider them). |
Closing this PR as #1188 (merged) has added the same feature. @KKSTB Thank you! cc @clalancette |
Adding a small feature to support timeout setting for rclpy.Client.call(). Hope it would be also useful for other users :)