8000 make NT the exception · ethervoid/client_python@1089530 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1089530

Browse files
committed
make NT the exception
Signed-off-by: Sander Van de Moortel <sander.vandemoortel@gmail.com>
1 parent 3688edd commit 1089530

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

prometheus_client/exposition.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,7 @@ def write_to_textfile(path, registry):
273273
f.write(generate_latest(registry))
274274

275275
# rename(2) is atomic but fails on Windows if the destination file exists
276-
if os.name == 'posix':
277-
os.rename(tmppath, path)
278-
else:
276+
if os.name == 'nt':
279277
if sys.version_info <= (3, 3):
280278
# Unable to guarantee atomic rename on Windows and Python<3.3
281279
# Remove and rename instead (risks losing the file)
@@ -285,6 +283,8 @@ def write_to_textfile(path, registry):
285283
# os.replace is introduced in Python 3.3 but there is some dispute whether
286284
# it is a truly atomic file operation: https://bugs.python.org/issue8828
287285
os.replace(tmppath, path)
286+
else:
287+
os.rename(tmppath, path)
288288

289289

290290
def _make_handler(url, method, timeout, headers, data, base_handler):

0 commit comments

Comments
 (0)
0