From c60eb883f1976dbae452f64db6b07eb1ebf5fdbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Tue, 3 Dec 2024 20:14:36 +0100 Subject: [PATCH] fix: handle exceptions if readline history fails to write --- gptme/util/readline.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gptme/util/readline.py b/gptme/util/readline.py index 18d6d645..0971a472 100644 --- a/gptme/util/readline.py +++ b/gptme/util/readline.py @@ -36,7 +36,11 @@ def add_history(line: str) -> None: # pragma: no cover load_readline_history() readline.add_history(line) - readline.write_history_file(get_readline_history_file()) + hist_file = get_readline_history_file() + try: + readline.write_history_file(hist_file) + except Exception as e: + logger.warning(f"Failed to write history file {hist_file}: {e}") def load_readline_history() -> None: # pragma: no cover