-
Notifications
You must be signed in to change notification settings - Fork 336
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
Don't call shutdown() after an exception #1400
Conversation
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.
Isn't finally also applied even for the case without exception?
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1400 +/- ##
==========================================
+ Coverage 83.58% 83.63% +0.04%
==========================================
Files 122 122
Lines 10990 10984 -6
Branches 935 933 -2
==========================================
Hits 9186 9186
+ Misses 1492 1488 -4
+ Partials 312 310 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
yes, but spin() never will exit without an exception, am I right? I'm not sure if destroy_node() is necessary at all: The examples on docs.ros.org don't do this, except here:
|
Without having the definite answer - my understanding is that you can not exit a) Something throws an exception during the spin (e.g. one of your callbacks) But when would you like to explicitly destroy a node?Behind the node there is always the The reason why there are methods for destroying publisher/subscription etc. and nodes is that the default garbage collection mechanism of python doesn't work with those. There is always a corresponding native object in the rcl layer and therefore it is necessary to manually release resources. (I've seen that there is some work done in rclpy to implement those as Btw. if you need ROS communication after leaving spin due to an exception it is possible to create a new context and perform any communication inside that. |
Thanks for the background info. Would you say that the current state is fine then? I mean, this is a test node and not productive code, but still like to understand how to properly design this ;) |
..._controllers_test_nodes/ros2_controllers_test_nodes/publisher_joint_trajectory_controller.py
Outdated
Show resolved
Hide resolved
See my comment. I also think the rclpy documentation is not very clear about this - in addition there are also some things that not work the way they should (see the on_shutdown hook for example) |
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.
Sounds fine. I hope it works the same back in Humble too
(cherry picked from commit b9a7cfc)
Closes #1383 acc. to the hint given by @firesurfer