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 bf210bb commit 9e6b2f0
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 9e6b2f0

Please sign in to comment.