Skip to content

Commit

Permalink
Use context manager form of rclpy.init()
Browse files Browse the repository at this point in the history
Signed-off-by: Shane Loretz <[email protected]>
  • Loading branch information
sloretz committed Oct 15, 2024
1 parent f6f6602 commit 79009b7
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down

0 comments on commit 79009b7

Please sign in to comment.