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 16, 2024
1 parent a839c3b commit cf37f1d
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down

0 comments on commit cf37f1d

Please sign in to comment.