From cd036f4935f07ea464059fa6a389eec0ec6df2a5 Mon Sep 17 00:00:00 2001 From: Wei Hu Date: Thu, 26 Sep 2024 23:03:25 +0800 Subject: [PATCH] Avoid too many characters cached in buffer Signed-off-by: Wei Hu --- launch/launch/actions/execute_local.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/launch/launch/actions/execute_local.py b/launch/launch/actions/execute_local.py index 9c5367173..b545e442d 100644 --- a/launch/launch/actions/execute_local.py +++ b/launch/launch/actions/execute_local.py @@ -375,14 +375,14 @@ def __on_process_output( buffer.write(to_write) buffer.seek(0) last_line = None + MAX_CHARACTER_KEPT_BEFORE_LOG = 4096 for line in buffer: - if line.endswith(os.linesep): + if line.endswith('\n') or len(line) >= MAX_CHARACTER_KEPT_BEFORE_LOG: logger.info( - self.__output_format.format(line=line[:-len(os.linesep)], this=self) + self.__output_format.format(line=line.rstrip(os.linesep), this=self) ) else: last_line = line - break buffer.seek(0) buffer.truncate(0) if last_line is not None: