Skip to content

Commit d8b16ef

Browse files
authored
Merge pull request #215 from ipums/bug-fix-history-file
Don't create a history file on startup
2 parents e84c5d2 + b26cd33 commit d8b16ef

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

hlink/scripts/main.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,12 @@ def _get_spark(run_name: str, args: argparse.Namespace) -> SparkSession:
172172

173173

174174
def _read_history_file(history_file):
175-
if not os.path.exists(history_file):
176-
with open(history_file, "a"):
177-
os.utime(history_file, (1330712280, 1330712292))
178-
readline.read_history_file(history_file)
175+
try:
176+
readline.read_history_file(history_file)
177+
except FileNotFoundError:
178+
# There's no history file, which is fine. Hlink will create a new one
179+
# when it shuts down.
180+
pass
179181

180182

181183
def _cli_loop(spark, args, run_conf, run_name):

hlink/tests/main_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from hlink.scripts.main import _read_history_file
2+
3+
4+
def test_read_history_file_does_not_exist(tmp_path) -> None:
5+
"""
6+
_read_history_file() does not raise an exception if the history file does
7+
not exist.
8+
"""
9+
history_file = tmp_path / ".history_notthere"
10+
_read_history_file(history_file)

0 commit comments

Comments
 (0)