Fix write_to_textfile leaves back temp files on errors#1066
Fix write_to_textfile leaves back temp files on errors#1066csmarchbanks merged 1 commit intoprometheus:masterfrom ethanschen:master
write_to_textfile leaves back temp files on errors#1066Conversation
write_to_textfile leaves back temp files on errors
Signed-off-by: Ethan S. Chen <ethanschen@163.com>
|
Looks in good to me. The only two things I'd comment are:
|
Thanks. Regarding your first point, I believe the As for the second point, if the Traceback (most recent call last):
File "/WorkSpace/venv/lib/python3.8/site-packages/prometheus_client/exposition.py", line 378, in write_to_textfile
os.rename(tmppath, path)
FileNotFoundError: [Errno 2] No such file or directory: '.80904.140704537089984' -> ''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "x.py", line 6, in <module>
write_to_textfile('', registry)
File "/WorkSpace/venv/lib/python3.8/site-packages/prometheus_client/exposition.py", line 381, in write_to_textfile
os.remove(1/0)
ZeroDivisionError: division by zeroTherefore, I think avoiding nested exception handling code might make it more elegant. |
csmarchbanks
left a comment
There was a problem hiding this comment.
👍 I agree that handling keyboard interrupts is not needed and keeping this as simple as possible is nice. Thanks!
Fix #1044