Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write_to_textfile leaves back temp files on errors #1044

Closed
calestyo opened this issue Jul 4, 2024 · 2 comments · Fixed by #1066
Closed

write_to_textfile leaves back temp files on errors #1044

calestyo opened this issue Jul 4, 2024 · 2 comments · Fixed by #1066
Labels

Comments

@calestyo
Copy link

calestyo commented Jul 4, 2024

Hey.

A simple:

prometheus_client.write_to_textfile("", registry=registry)

which causes an exception:

Traceback (most recent call last):
  File "/home/calestyo/prj/prometheus-smart-array-collector/src/./smart-array.py", line 1185, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/calestyo/prj/prometheus-smart-array-collector/src/./smart-array.py", line 1176, in main
    prometheus_client.write_to_textfile("", registry=registry)
  File "/usr/lib/python3/dist-packages/prometheus_client/exposition.py", line 363, in write_to_textfile
    os.rename(tmppath, path)
FileNotFoundError: [Errno 2] No such file or directory: '.969277.139657657282624' -> ''

shows that the module doesn't properly clean up it's temp files on errors, as that file is left over afterwards.

Cheers,
Chris.

@csmarchbanks
Copy link
Member

Seems reasonable to avoid leaving around tons of temporary files, though they will be cleaned up eventually. I'd be happy to accept a PR.

ethanschen added a commit to ethanschen/client_python that referenced this issue Oct 16, 2024
ethanschen added a commit to ethanschen/client_python that referenced this issue Oct 16, 2024
ethanschen added a commit to ethanschen/client_python that referenced this issue Oct 16, 2024
@ethanschen
Copy link
Contributor

ethanschen commented Oct 16, 2024

PTAL #1066 @calestyo @csmarchbanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants