diff --git a/source/How-To-Guides/Migrating-from-ROS1/Migrating-Python-Package-Example.rst b/source/How-To-Guides/Migrating-from-ROS1/Migrating-Python-Package-Example.rst index 2f109176f0..69d6864354 100644 --- a/source/How-To-Guides/Migrating-from-ROS1/Migrating-Python-Package-Example.rst +++ b/source/How-To-Guides/Migrating-from-ROS1/Migrating-Python-Package-Example.rst @@ -850,13 +850,11 @@ Your refactored code might look like this: def main(): - rclpy.init() try: - rclpy.spin(Talker()) + with rclpy.init(): + rclpy.spin(Talker()) except (ExternalShutdownException, KeyboardInterrupt): - pass - finally: - rclpy.try_shutdown() + pass Conclusion ----------