Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -577,9 +577,10 @@ def __flush_buffers(self, event, context):
self.__stderr_buffer.truncate(0)

def __on_shutdown(self, event: Event, context: LaunchContext) -> Optional[SomeActionsType]:
due_to_sigint = cast(Shutdown, event).due_to_sigint
return self._shutdown_process(
context,
send_sigint=(not cast(Shutdown, event).due_to_sigint),
send_sigint=not due_to_sigint or context.noninteractive,
)

def __get_shutdown_timer_actions(self) -> List[Action]:
Expand Down
14 changes: 13 additions & 1 deletion launch/launch/launch_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,20 @@
class LaunchContext:
"""Runtime context used by various launch entities when being visited or executed."""

def __init__(self, *, argv: Optional[Iterable[Text]] = None) -> None:
def __init__(
self, *,
argv: Optional[Iterable[Text]] = None,
noninteractive: bool = False
) -> None:
"""
Create a LaunchContext.

:param: argv stored in the context for access by the entities, None results in []
:param: noninteractive if True (not default), this service will assume it has
no terminal associated e.g. it is being executed from a non interactive script
"""
self.__argv = argv if argv is not None else []
self.__noninteractive = noninteractive

self._event_queue = asyncio.Queue() # type: asyncio.Queue
self._event_handlers = collections.deque() # type: collections.deque
Expand All @@ -63,6 +70,11 @@ def argv(self):
"""Getter for argv."""
return self.__argv

@property
def noninteractive(self):
"""Getter for noninteractive."""
return self.__noninteractive

def _set_is_shutdown(self, state: bool) -> None:
self.__is_shutdown = state

Expand Down
5 changes: 4 additions & 1 deletion launch/launch/launch_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(
self,
*,
argv: Optional[Iterable[Text]] = None,
noninteractive: bool = False,
debug: bool = False
) -> None:
"""
Expand All @@ -67,6 +68,8 @@ def __init__(
outside of the main-thread.

:param: argv stored in the context for access by the entities, None results in []
:param: noninteractive if True (not default), this service will assume it has
no terminal associated e.g. it is being executed from a non interactive script
:param: debug if True (not default), asyncio the logger are seutp for debug
"""
# Setup logging and debugging.
Expand All @@ -82,7 +85,7 @@ def __init__(
install_signal_handlers()

# Setup context and register a built-in event handler for bootstrapping.
self.__context = LaunchContext(argv=self.__argv)
self.__context = LaunchContext(argv=self.__argv, noninteractive=noninteractive)
self.__context.register_event_handler(OnIncludeLaunchDescription())
self.__context.register_event_handler(OnShutdown(on_shutdown=self.__on_shutdown))

Expand Down