Skip to content

Commit

Permalink
Merge pull request #32 from T045T/patch-1
Browse files Browse the repository at this point in the history
make ServiceState more robust to termination while waiting for service
  • Loading branch information
jbohren committed Dec 2, 2014
2 parents e0180ad + d7fb5e4 commit 3548a59
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion smach_ros/src/smach_ros/service_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3548a59

Please sign in to comment.