From ee89dc14c8dbe40f256b0d96d97e5535affe09a4 Mon Sep 17 00:00:00 2001 From: Ivan Santiago Paunovic Date: Thu, 1 Dec 2022 15:33:14 -0300 Subject: [PATCH] Address peer review comments Signed-off-by: Ivan Santiago Paunovic --- launch/launch/actions/execute_local.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/launch/launch/actions/execute_local.py b/launch/launch/actions/execute_local.py index 865534ccd..f115d8ef1 100644 --- a/launch/launch/actions/execute_local.py +++ b/launch/launch/actions/execute_local.py @@ -541,8 +541,6 @@ async def _signal_subprocesses(self, context): log_prefix_format = ( 'subprocess[pid={}] of process[' f'{process_name}, pid={process_pid}]: ') - # signal_subprocesses_timeout_v = perform_substitutions( - # context, signal_subprocesses_timeout) next_signals = iter(((signal.SIGTERM, sigterm_timeout), (signal.SIGKILL, sigkill_timeout))) while True: for p in to_signal: @@ -559,13 +557,15 @@ async def _signal_subprocesses(self, context): sig, timeout = next(next_signals) except StopIteration: return - while context.asyncio_loop.time() < start_time + timeout: - await asyncio.sleep(0.5) + current_time = context.asyncio_loop.time() + while current_time < start_time + timeout: + await asyncio.sleep(min(0.5, start_time + timeout - current_time)) for p in list(signaled): - log_prefix = log_prefix_format.format(p.pid) if not p.is_running(): - self.__logger.info(f'{log_prefix} exited') + log_prefix = log_prefix_format.format(p.pid) + self.__logger.info(f'{log_prefix}exited') signaled.remove(p) + current_time = context.asyncio_loop.time() to_signal = signaled signaled = []