Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed to exit program #146

Open
canalteks opened this issue Jul 26, 2019 · 0 comments
Open

failed to exit program #146

canalteks opened this issue Jul 26, 2019 · 0 comments

Comments

@canalteks
Copy link

Dear developers,

we found that python actionlib.SimpleActionServer will block to exit program, when we raise an exception. the following codes will reproduce the problem.

import rospy
import actionlib
from actionlib.msg import TestAction
from actionlib.msg import TestActionResult

class test_t( object ):
    def procedure( self ):
        #rospy.signal_shutdown('signal shutdown')  # uncomment to exit program
        raise rospy.ROSException('exit program')  # raise an exception for test

    def goal_callback( self ):
        self.goal = self.as_tline.accept_new_goal()

    def preempt_callback( self ):
        res               = TestActionResult()
        res.result.result = -1

    def __init__( self ):
        self.goal = None
        self.action_server = actionlib.SimpleActionServer( 'test_action', TestAction, auto_start = False )
        self.action_server.register_goal_callback   ( self.goal_callback    )
        self.action_server.register_preempt_callback( self.preempt_callback )
        #
        self.action_server.start() # if we did not start ActionServer, program will exit properly.

if __name__ == '__main__':
    try:
        rospy.init_node( 'testnode' )

        test = test_t()
        test.procedure()

    except rospy.ROSException as e:
        print( e )

    print( 'terminated' )  # we can see this message, but program will never exit.

we can see 'terminated' message on the console, but the program is still running.
only kill -9 PID can stop the program.

to exit this program properly, we need rospy.signal_shutdown() before raising an exception, or do not to start SimpleActionServer by self.action_server.start().
we feel that actionlib.ActionServer.status_timer cannot stop, because that actionlib.ActionServer has no __del__ method to join the thread of the status_timer (in spite of that, actionlib.SimpleActionServer has __del__).

specifications of our development environment:

  • Debian Strech
  • ROS Melodic
  • Actionlib 1.11.13-0stretch.20190606.072225

we hope that it could be help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant