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

Re-spawn a process only if returncode != 0 #514

Draft
wants to merge 4 commits into
base: rolling
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion launch/launch/actions/execute_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,8 @@ async def __execute_process(self, context: LaunchContext) -> None:
))
await context.emit_event(ProcessExited(returncode=returncode, **process_event_args))
# respawn the process if necessary
if not context.is_shutdown and not self.__shutdown_future.done() and self.__respawn:
if not context.is_shutdown and not self.__shutdown_future.done() and self.__respawn and \
returncode != 0:
if self.__respawn_delay is not None and self.__respawn_delay > 0.0:
# wait for a timeout(`self.__respawn_delay`) to respawn the process
# and handle shutdown event with future(`self.__shutdown_future`)
Expand Down
2 changes: 1 addition & 1 deletion launch/test/launch/test_execute_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def generate_launch_description():
return LaunchDescription([

ExecuteProcess(
cmd=[sys.executable, '-c', "print('action')"],
cmd=[sys.executable, '-c', "import sys; print('action'); sys.exit(1)"],
respawn=True, respawn_delay=respawn_delay, on_exit=on_exit_callback
),

Expand Down