ros2 / examples

Example packages for ROS 2
Apache License 2.0
703 stars 312 forks source link

Update the shutdown handling in all of the Python examples. #379

Closed clalancette closed 5 months ago

clalancette commented 5 months ago

In particular, we should deal with KeyboardInterrupt (by just doing 'pass'), as well as ExternalShutdownException (which can come from the executor). In all cases, we should call 'rclpy.try_shutdown()' to cleanup at the end.

Note well that I removed some of the *destroy() calls in the cleanup. That's because they weren't correct in all cases, and to fix them up properly would really require us to have a nested set of try..except statements. Given that these are examples, having that complex set of exception handling didn't seem like the correct way to go here.

This should fix #372 . @fujitatomoya FYI

clalancette commented 5 months ago

CI:

clalancette commented 5 months ago

CI:

clalancette commented 5 months ago

Going ahead and merging this one in.