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 0a076454b4..a52dc1019f 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 @@ -848,13 +848,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 ----------