Skip to content

Commit

Permalink
catch ExternalShutdownException ros2cli main. (#854)
Browse files Browse the repository at this point in the history
Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
  • Loading branch information
fujitatomoya authored Oct 1, 2023
1 parent 2a25342 commit 0084d12
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ros2cli/ros2cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import signal
import sys

from rclpy.executors import ExternalShutdownException

from ros2cli.command import add_subparsers_on_demand


Expand Down Expand Up @@ -89,6 +91,8 @@ def main(*, script_name='ros2', argv=None, description=None, extension=None):
rc = extension.main(parser=parser, args=args)
except KeyboardInterrupt:
rc = signal.SIGINT
except ExternalShutdownException:
rc = signal.SIGTERM
except RuntimeError as e:
rc = str(e)
return rc

0 comments on commit 0084d12

Please sign in to comment.