From 65bd653621b0b8a8d8bab318dd63e75695f1d902 Mon Sep 17 00:00:00 2001 From: Ruddick Lawrence <679360+mrjogo@users.noreply.github.com> Date: Thu, 16 May 2024 00:52:06 -0700 Subject: [PATCH] Add guard on Python single goal action server example (#380) Signed-off-by: Ruddick Lawrence <679360+mrjogo@users.noreply.github.com> --- .../server_single_goal.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rclpy/actions/minimal_action_server/examples_rclpy_minimal_action_server/server_single_goal.py b/rclpy/actions/minimal_action_server/examples_rclpy_minimal_action_server/server_single_goal.py index fe8824c6..a172963c 100644 --- a/rclpy/actions/minimal_action_server/examples_rclpy_minimal_action_server/server_single_goal.py +++ b/rclpy/actions/minimal_action_server/examples_rclpy_minimal_action_server/server_single_goal.py @@ -100,7 +100,12 @@ def execute_callback(self, goal_handle): # Sleep for demonstration purposes time.sleep(1) - goal_handle.succeed() + with self._goal_lock: + if not goal_handle.is_active: + self.get_logger().info('Goal aborted') + return Fibonacci.Result() + + goal_handle.succeed() # Populate result message result = Fibonacci.Result()