diff --git a/demo/runners/support/agent.py b/demo/runners/support/agent.py index 0aa7f995ed..45e3b317bd 100644 --- a/demo/runners/support/agent.py +++ b/demo/runners/support/agent.py @@ -662,7 +662,18 @@ def handle_output(self, *output, source: str = None, **kwargs): color = self.color or "fg:ansiblue" else: color = None - log_msg(*output, color=color, prefix=self.prefix_str, end=end, **kwargs) + try: + log_msg(*output, color=color, prefix=self.prefix_str, end=end, **kwargs) + except AssertionError as e: + if self.trace_enabled and self.trace_target == "log": + # when tracing to a log file, + # we hit an issue with the underlying prompt_toolkit. + # it attempts to output what is written by the log and can't find the + # correct terminal and throws an error. The trace log record does show + # in the terminal, so let's just ignore this error. + pass + else: + raise e def log(self, *msg, **kwargs): self.handle_output(*msg, **kwargs) diff --git a/demo/runners/support/utils.py b/demo/runners/support/utils.py index 63982d4437..0056686fbf 100644 --- a/demo/runners/support/utils.py +++ b/demo/runners/support/utils.py @@ -113,7 +113,12 @@ def output_reader(handle, callback, *args, **kwargs): for line in iter(handle.readline, b""): if not line: break - run_in_terminal(functools.partial(callback, line, *args)) + try: + run_in_terminal(functools.partial(callback, line, *args)) + except AssertionError as e: + # see comment in DemoAgent.handle_output + # trace log and prompt_toolkit do not get along... + pass def log_msg(*msg, color="fg:ansimagenta", **kwargs):