Skip to content

Commit

Permalink
Merge pull request #2245 from usingtechnology/bugfix/issue-2205
Browse files Browse the repository at this point in the history
./run_demo performance -c 1 --mediation --timing --trace-log
  • Loading branch information
swcurran committed May 30, 2023
2 parents c3ce923 + 5b6ecb0 commit 848eb35
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
13 changes: 12 additions & 1 deletion demo/runners/support/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,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)
Expand Down
7 changes: 6 additions & 1 deletion demo/runners/support/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 848eb35

Please sign in to comment.