Skip to content

Commit b9a7cfc

Browse files
Don't call shutdown() after an exception (ros-controls#1400)
1 parent cd73055 commit b9a7cfc

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

ros2_controllers_test_nodes/ros2_controllers_test_nodes/publisher_forward_position_controller.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,10 @@ def main(args=None):
7070

7171
try:
7272
rclpy.spin(publisher_forward_position)
73-
except KeyboardInterrupt:
73+
except (KeyboardInterrupt, rclpy.executors.ExternalShutdownException):
7474
print("Keyboard interrupt received. Shutting down node.")
7575
except Exception as e:
7676
print(f"Unhandled exception: {e}")
77-
finally:
78-
if rclpy.ok():
79-
publisher_forward_position.destroy_node()
80-
rclpy.shutdown()
8177

8278

8379
if __name__ == "__main__":

ros2_controllers_test_nodes/ros2_controllers_test_nodes/publisher_joint_trajectory_controller.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,10 @@ def main(args=None):
186186

187187
try:
188188
rclpy.spin(publisher_joint_trajectory)
189-
except KeyboardInterrupt:
189+
except (KeyboardInterrupt, rclpy.executors.ExternalShutdownException):
190190
print("Keyboard interrupt received. Shutting down node.")
191191
except Exception as e:
192192
print(f"Unhandled exception: {e}")
193-
finally:
194-
if rclpy.ok():
195-
publisher_joint_trajectory.destroy_node()
196-
rclpy.shutdown()
197193

198194

199195
if __name__ == "__main__":

0 commit comments

Comments
 (0)