Bug report
It looks like the callback that can be registered via context.on_shutdown is never called.
Required Info:
- Operating System:
- Installation type:
- Version or commit hash:
- Client library (if applicable):
Steps to reproduce issue
Register a callback to on_shutdown and then try various methods of exiting the node
def shutdown_handler():
print("exit")
def main(args=None):
rclpy.init(args=args)
node = Node("TestNode")
node.context.on_shutdown(shutdown_handler)
rclpy.get_default_context().on_shutdown(shutdown_handler)
rclpy.spin(node)
I tried sending various signals: SIGINT, SIGTERM, SIGQUIT
Expected behavior
exit should be printed twice
Actual behavior
Prints nothing
Additional information
I also tried calling try_shutdown:
try:
rclpy.spin(node)
except (KeyboardInterrupt, rclpy.executors.ExternalShutdownException):
pass
finally:
rclpy.try_shutdown()
But this didn't result into on_shutdown being called either.
If one tries to explicitly shutdown the context:
finally:
node.context.shutdown()
The following error is thrown:
failed to shutdown: rcl_shutdown already called on the given context
Related Issues
This issue is probably related to. But according to the issues I found on_shutdown should be at least called if the node is properly exited (or if try_shutdown is called?)
#532
#1077 <- This is actually what I am looking for as I do want to do some cleanup
Bug report
It looks like the callback that can be registered via
context.on_shutdownis never called.Required Info:
Steps to reproduce issue
Register a callback to on_shutdown and then try various methods of exiting the node
I tried sending various signals: SIGINT, SIGTERM, SIGQUIT
Expected behavior
exitshould be printed twiceActual behavior
Prints nothing
Additional information
I also tried calling
try_shutdown:But this didn't result into
on_shutdownbeing called either.If one tries to explicitly shutdown the context:
The following error is thrown:
failed to shutdown: rcl_shutdown already called on the given contextRelated Issues
This issue is probably related to. But according to the issues I found
on_shutdownshould be at least called if the node is properly exited (or if try_shutdown is called?)#532
#1077 <- This is actually what I am looking for as I do want to do some cleanup