-
Notifications
You must be signed in to change notification settings - Fork 913
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
Return the exit code a required process through roslaunch #2082
base: noetic-devel
Are you sure you want to change the base?
Conversation
92fad90
to
b28da16
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May solve #919
Please add a test :)
It looks like CI is failing. Please resolve the existing test failures.
6f45ed9
to
0acad1b
Compare
Made some cleanup and existing tests pass. A new test that launches a node with required=true then forces it to exit non-zero, then inspects roslaunch exit code is the next step. Any pointers to an existing roslaunch test that would be a good template for this would be very welcome, otherwise I'll figure it out eventually. I'll hold on to the remaining extra prints until I'm done with that, a few I think it makes sense to keep. |
Just tested this patch ported to melodic. Works for me! I did notice that the roslaunch xml node has to be marked as
|
would love to see this in melodic. Is there something I can do to help get this merged? |
… a regular parent launch process, child and remote processes need looking at. May solve ros#919
0acad1b
to
43e5388
Compare
Added a unit test, can run manually with
|
Try running lifecycle_test.launch - fails but doesn't result in a non-zero exit code (see ros/ros_comm#2082). Fix the test in a separate PR.
Try running lifecycle_test.launch (after adding a needed node to it) - works but doesn't result in a non-zero exit code if it does fail (see ros/ros_comm#2082). Turn it into a rostest in separate PR.
Try running lifecycle_test.launch (after adding a needed node to it) - works but doesn't result in a non-zero exit code if it does fail (see ros/ros_comm#2082). Turn it into a rostest in separate PR.
Can the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some review comments from my side, because I would also like to get the correct exit code from roslaunch. But I'm not a maintainer.
@sloretz Can you please also check the PR again?
@@ -363,6 +368,8 @@ def main(argv=sys.argv): | |||
try: os.unlink(options.pid_fn) | |||
except os.error: pass | |||
|
|||
print('exiting from main() {}'.format(exit_code)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a debug print that can be removed - people who are interested in the exit code of the executable can get this from the shell.
@@ -313,6 +314,8 @@ def main(argv=sys.argv): | |||
sigint_timeout=options.sigint_timeout, | |||
sigterm_timeout=options.sigterm_timeout) | |||
c.run() | |||
exit_code = c.exit_code | |||
logger.warn('child node {} done {}'.format(options.child_name, exit_code)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a warning? Looks more like a debug thing to me.
@@ -303,7 +304,7 @@ def main(argv=sys.argv): | |||
logger.info("roslaunch env is %s"%os.environ) | |||
|
|||
if options.child_name: | |||
logger.info('starting in child mode') | |||
logger.info('starting in child mode {}'.format(options.child_name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't starting {} in child mode
make more sense?
import sys | ||
# import time | ||
import unittest | ||
# import yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unnecessary imports
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
# Revision $Id: test_roslaunch_command_line_online.py 6411 2009-10-02 21:32:01Z kwc $ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this revision string looks like a copied thing that can be removed
#!/usr/bin/env python | ||
# Software License Agreement (BSD License) | ||
# | ||
# Copyright (c) 2014, The Johns Hopkins University |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The copyright notices look like they were pasted from somewhere else (2014 JHU, 2009 Willow) - do they make sense? I guess here the maintainers need to tell how this should be handled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like I copied it from test_roslaunch_ros_args.py
.
Copyright (c) 2008, Willow Garage, Inc
isn't true either, should it be Open Robotics 2021, or my name?
@@ -618,7 +619,7 @@ def spin(self): | |||
#self.pm.join() | |||
self.logger.info("process monitor is done spinning, initiating full shutdown") | |||
self.stop() | |||
printlog_bold("done") | |||
printlog_bold("roslaunch runner done") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave this as it is, it's unrelated to the feature.
@@ -566,6 +567,10 @@ def _run(self): | |||
if p.required: | |||
printerrlog('='*80+"REQUIRED process [%s] has died!\n%s\nInitiating shutdown!\n"%(p.name, exit_code_str)+'='*80) | |||
self.is_shutdown = True | |||
if p.exit_code != 0: | |||
msg = 'Going to exit due to code {}'.format(p.exit_code) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also include the p.name
of the dead process:
msg = 'Going to exit due to non-zero exit code ({}) of required process {}'.format(p.exit_code, p.name)
@@ -346,6 +349,8 @@ def main(argv=sys.argv): | |||
sigterm_timeout=options.sigterm_timeout) | |||
p.start() | |||
p.spin() | |||
exit_code = p.exit_code | |||
print('ending server mode {}'.format(exit_code)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here, is this print needed?
e88055b
to
279cdb2
Compare
Try running lifecycle_test.launch (after adding a needed node to it) - works but doesn't result in a non-zero exit code if it does fail (see ros/ros_comm#2082). Turn it into a rostest in separate PR.
Return the exit code to the caller of a required process at least for a regular parent launch process, child and remote processes need looking at.
May solve #919