You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm a little bit puzzled about the fact that the code in the finally branch has zero coverage. maybe rlcpy.ok() is always false here. Should the destroy_node() be called even if the context is not valid any more? @saikishor any idea?
I did some research when looking into this: ros2/rclpy#1287 and if I understood it correctly
the context becomes invalid after leaving the spin with an exception.
In our main python node we have this weird looking construct:
retry_counter = 0
while rclpy.ok():
try:
rclpy.spin(node)
retry_counter += 1
except (KeyboardInterrupt, rclpy.executors.ExternalShutdownException):
break
except Exception as ex:
node.get_logger().error(str(ex))
node.get_logger().error(str(traceback.format_exc()))
if retry_counter > 10:
break
The retry_counter was/(is ?) a workaround for a just once in a while occurring issue with rclpy where it would throw an exception but the context was still okey. The loggers are still operational afterwards btw. but do not log to ros_out anymore - only to the stdout.
TLDR:
I would say: Do not call shutdown when exiting spin with an exception as the context is already destroyed.
If you need ROS communication afterwards: You can create a new context and create new node in that context.
I'm a little bit puzzled about the fact that the code in the finally branch has zero coverage. maybe rlcpy.ok() is always false here. Should the destroy_node() be called even if the context is not valid any more? @saikishor any idea?
Originally posted by @christophfroehlich in #1369 (comment)
This does not happen always, but if it enters there is a different error
https://github.com/ros-controls/ros2_controllers/actions/runs/11972094365/job/33378268325?pr=1314
The text was updated successfully, but these errors were encountered: