Skip to content

Clean up leaked temp files in check_gguf.py - #2

Open
SID-6921 wants to merge 1 commit into
udgamlabs:mainfrom
SID-6921:fix/gguf-tempfile-leak
Open

SID-6921 wants to merge 1 commit into
udgamlabs:mainfrom
SID-6921:fix/gguf-tempfile-leak

Conversation

@SID-6921

@SID-6921 SID-6921 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Both temp-file sites in gguf/check_gguf.py create a NamedTemporaryFile(delete=False, ...) and never remove the file afterward:

  • llama_ids() creates one per call, so with the default --pages 40 it leaks up to 40 files per GGUF argument on every run.
  • the perplexity section of main() creates one more for the concatenated text sample used across all GGUFs.

delete=False has to stay, since llama-tokenize/llama-perplexity read the path after the with block closes the file handle. This wraps the subsequent usage in try/finally and calls os.unlink() once each file is no longer needed, so the temp dir does not accumulate files run after run.

llama_ids() and the perplexity sample in main() both created
NamedTemporaryFile(delete=False) and never removed the file, leaking
a temp file per page per GGUF (and one more for the perplexity text
sample) into the OS temp dir on every run. delete=False still has to
stay since llama-tokenize/llama-perplexity read the path after the
with block closes the handle, so wrap the subprocess usage in
try/finally and os.unlink() once it is done.
Copilot AI balanced review requested due to automatic review settings November 10, 2026 05:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants