-
Notifications
You must be signed in to change notification settings - Fork 9
Avoid blocking forever in RCLFuture.get() with timeout #78
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
Conversation
Add overloads for spinOnce methods to include a timeout argument and call this when spinning in the future. This fixes a bug where the future.get(...) call blocks forever, e.g. when waiting on a service response and the service becomes unavailable. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
ivanpauno
left a comment
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.
The fact that the Future returned is calling spin() behind the scenes when you call get() is already a problem, because the current executor doesn't support to be spinned in parallel.
IMO the returned future should not call spin().
We could for example use the java intrinsic wait/notify methods.
Makes sense to me. In any case, do you see any issue in adding the new RCLJava spin methods? It'd be nice to get this fix in and then refactor to avoid calling spin in |
|
For instance, without this change the example breaks (hangs forever) if we add the timeout argument to this call: |
No, this is not adding a new problem, so I think it's fine to merge this PR.
How does that happen? Is there no server running? rclcpp has a similar issue ros2/rclcpp#1697. |
Yes, we can contrive an example where we don't wait for a service and directly send a request. Even if we call |
Yes, that used to happen in some rmw implementations. |
Add overloads for spinOnce methods to include a timeout argument and call this when spinning in the future. This fixes a bug where the future.get(...) call blocks forever, e.g. when waiting on a service response and the service becomes unavailable. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
|
Hello, for my term project I am trying to use ros2_java project. I have a subscriber that I am activating by RCLJava.spin and i am doing this in a new thread. But as soon as spin is called all the other stuff that is being executed stopping, so RCLJava.spin block all the other work and it does not subscribe to the topic without this command. I dont know if this is the right place to post it but I thought i can find an answer here. All help is appreciated, thank you in advanced |
Add overloads for spinOnce methods to include a timeout argument and call this when spinning in the future.
This fixes a bug where the future.get(...) call blocks forever, e.g. when waiting on a service response and the service becomes unavailable.