8000 forego deletion if file isn't found · ethervoid/client_python@20a31b4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 20a31b4

Browse files
committed
forego deletion if file isn't found
Signed-off-by: Sander Van de Moortel <sander.vandemoortel@gmail.com>
1 parent 1089530 commit 20a31b4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

prometheus_client/exposition.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,11 @@ def write_to_textfile(path, registry):
277277
if sys.version_info <= (3, 3):
278278
# Unable to guarantee atomic rename on Windows and Python<3.3
279279
# Remove and rename instead (risks losing the file)
280-
os.remove(path)
280+
try:
281+
os.remove(path)
282+
except FileNotFoundError:
283+
pass
284+
281285
os.rename(tmppath, path)
282286
else:
283287
# os.replace is introduced in Python 3.3 but there is some dispute whether

0 commit comments

Comments
 (0)
0