Skip to content
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

Make lifecycle demo automatically exit when done #558

Merged
merged 1 commit into from
Apr 8, 2022

Conversation

sloretz
Copy link
Contributor

@sloretz sloretz commented Apr 7, 2022

Fixes #504

This makes the lifecyle demo automatically exit when it's completed. First this PR fixes a bug in lifecycle_service_client where it's stuck waiting for the future to complete forever because of ros2/rclcpp#1916. Next this PR adds a Shutdown action to the on_exit argument of the lifecycle_service_client Node so that when it shuts down the other nodes are killed too.

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
@sloretz sloretz requested a review from mjeronimo April 7, 2022 22:15
@sloretz
Copy link
Contributor Author

sloretz commented Apr 7, 2022

CI (build: --packages-up-to lifecycle test: --packages-select lifecycle)

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

@sloretz sloretz merged commit 0cf803e into master Apr 8, 2022
@delete-merged-branch delete-merged-branch bot deleted the sloretz__lifecycle__exit_demo_when_done branch April 8, 2022 16:01
@@ -321,6 +330,10 @@ int main(int argc, char ** argv)
std::shared_future<void> script = std::async(
std::launch::async,
std::bind(callee_script, lc_client));
auto wake_exec = std::async(
std::launch::async,
std::bind(wake_executor, script, std::ref(exe)));
Copy link
Member

Choose a reason for hiding this comment

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

I would say this is unnecessarily complicated. I would instead move the callee_script into a one-off timer with zero duration.

Or better yet, run the executor's spin in a separate thread (use std::async if you like) and do the callee_script here in the main thread, then when that function is done cancel the executor and "join" the thread it was using to spin in.

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.

[lifecycle demo] Launch script doesn't exit
3 participants