Skip to content

add note about problems with spin_until_future_complete #2849

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

Open
wants to merge 1 commit into
base: rolling
Choose a base branch
from

Conversation

alsora
Copy link
Collaborator

@alsora alsora commented May 17, 2025

Description

The spin_until_future_complete can lead to unexpected behaviors.
It will only check if the future is complete when the timeout expires or after executing an executor's entity.

This will work as expected only if there's an event waking up the executor when the future becomes ready.
For example this will happen when doing a ROS client request and receiving a future.

auto future = client.async_send_request(request);
executor.spin_until_future_complete(future);

But it will not work correctly for any other generic future

auto future = my_non_ros_stuff();
executor.spin_until_future_complete(future);

In particular we may end up spinning for a lot more after the future is complete.

Is this user-facing behavior change?

No, just adding a comment

Did you use Generative AI?

No

Additional Information

This same problem is discussed as part of #2475

…ly with futures generated by ROS entities

Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>
Comment on lines +375 to +376
* If this future is unrelated to an executor's entity, this method will not detect correctly
* when it's completed.
Copy link
Collaborator

Choose a reason for hiding this comment

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

we need the indents here?

Suggested change
* If this future is unrelated to an executor's entity, this method will not detect correctly
* when it's completed.
* If this future is unrelated to an executor's entity, this method will not detect correctly
* when it's completed.

Comment on lines +374 to +376
* \note This method will check the future and the timeout only when the executor is woke up.
* If this future is unrelated to an executor's entity, this method will not detect correctly
* when it's completed.
Copy link
Member

Choose a reason for hiding this comment

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

Minor fix + indentation to match the rest:

Suggested change
* \note This method will check the future and the timeout only when the executor is woke up.
* If this future is unrelated to an executor's entity, this method will not detect correctly
* when it's completed.
* \note This method will check the future and the timeout only when the executor is woken up.
* If this future is unrelated to an executor's entity, this method will not detect correctly
* when it's completed.

Should we also be more explicit about what could happen, e.g., "will not correctly detect when it's completed and therefore may wait forever and never time out."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants