Skip to content

Commit

Permalink
Something that might work.
Browse files Browse the repository at this point in the history
  • Loading branch information
rohe committed Feb 20, 2024
1 parent a706720 commit 57b8cd5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/idpyoidc/storage/listfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,14 @@ def get_mtime(fname):
:param fname: File name
:return: The last time the file was modified.
"""
p = Path(fname)
try:
target = Path(fname)
mtime = target.stat().st_mtime
# mtime = os.stat(fname).st_mtime_ns
mtime = p.stat().st_mtime
except OSError:
# The file might be right in the middle of being written to
# The file might be right in the middle of being created
# so sleep
time.sleep(1)
target = Path(fname)
mtime = target.stat().st_mtime
# mtime = os.stat(fname).st_mtime_ns
mtime = p.stat().st_mtime

return mtime

Expand Down
2 changes: 2 additions & 0 deletions tests/test_14_read_only_list_file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from time import sleep

from idpyoidc.storage.listfile import ReadOnlyListFile

Expand All @@ -22,6 +23,7 @@ def test_read_only_list_file():
for line in ["one", "two", "three"]:
fp.write(line + '\n')

sleep(1)
assert len(_read_only) == 3
assert set(_read_only) == {"one", "two", "three"}
assert _read_only[-1] == "three"

0 comments on commit 57b8cd5

Please sign in to comment.