From d7fb5e45badec552ec9835171b21e26ab38ed05e Mon Sep 17 00:00:00 2001 From: Nils Berg Date: Tue, 2 Dec 2014 18:55:18 +0100 Subject: [PATCH] make ServiceState more robust to termination while waiting for service --- smach_ros/src/smach_ros/service_state.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/smach_ros/src/smach_ros/service_state.py b/smach_ros/src/smach_ros/service_state.py index 9467c03..9b298fe 100644 --- a/smach_ros/src/smach_ros/service_state.py +++ b/smach_ros/src/smach_ros/service_state.py @@ -115,11 +115,14 @@ def execute(self, ud): # Make sure we're connected to the service try: - while not rospy.is_shutdown() and self._proxy is None: + while self._proxy is None: if self.preempt_requested(): rospy.loginfo("Preempting while waiting for service '%s'." % self._service_name) self.service_preempt() return 'preempted' + if rospy.is_shutdown(): + rospy.loginfo("Shutting down while waiting for service '%s'." % self._service_name) + return 'aborted' try: rospy.wait_for_service(self._service_name,1.0) self._proxy = rospy.ServiceProxy(self._service_name, self._service_spec)