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

Pre-Shutdown Hooks / Humble #1077

Open
stonier opened this issue Feb 4, 2023 · 0 comments
Open

Pre-Shutdown Hooks / Humble #1077

stonier opened this issue Feb 4, 2023 · 0 comments

Comments

@stonier
Copy link
Contributor

stonier commented Feb 4, 2023

Feature request

Feature description

Hooks that run immediately prior to shutdown. It used to be possible prior to humble with:

try:
   rclpy.spin(my.node)
except (KeyboardInterrupt):
   // make some rclpy service calls
   my.node.destroy_node()
   rclpy.shutdown()

It looks like this is no longer possible since context shutdowns happen automagically.

Typical humble code now looks like:

    try:
        rclpy.spin(led_strip.node)
    except (KeyboardInterrupt, rclpy.executors.ExternalShutdownException):
        // context is already gone at this point
        pass
    finally:
        rclpy.try_shutdown()

Implementation considerations

rclpy has an on_shutdown` hook in but that comes too late (i.e. after shutdown).

rclcpp has a pre_shutdown hook: ros2/rclcpp#1714 but this is not available in rclpy.

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

No branches or pull requests

1 participant