Skip to content

Commit 57b8cd5

Browse files
committed
Something that might work.
1 parent a706720 commit 57b8cd5

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/idpyoidc/storage/listfile.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,14 @@ def get_mtime(fname):
4040
:param fname: File name
4141
:return: The last time the file was modified.
4242
"""
43+
p = Path(fname)
4344
try:
44-
target = Path(fname)
45-
mtime = target.stat().st_mtime
46-
# mtime = os.stat(fname).st_mtime_ns
45+
mtime = p.stat().st_mtime
4746
except OSError:
48-
# The file might be right in the middle of being written to
47+
# The file might be right in the middle of being created
4948
# so sleep
5049
time.sleep(1)
51-
target = Path(fname)
52-
mtime = target.stat().st_mtime
53-
# mtime = os.stat(fname).st_mtime_ns
50+
mtime = p.stat().st_mtime
5451

5552
return mtime
5653

tests/test_14_read_only_list_file.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from time import sleep
23

34
from idpyoidc.storage.listfile import ReadOnlyListFile
45

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

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

0 commit comments

Comments
 (0)