Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1828.
Importing llama_cpp opens two null-device streams. With Python resource warnings enabled, exiting the interpreter reports both streams as unclosed. I reproduced this on Windows with just
import llama_cpp.Open the null device when a suppression scope begins and close it when the scope ends. Python streams, native file descriptors and ipykernel stream copies are restored on exit. An explicit encoding and a saved reference to
openlet a destructor use the same scope during interpreter shutdown.The new subprocess test exercises nested suppression, writes to native file descriptors, restoration of stdout and stderr, and a destructor that suppresses output during shutdown. On the original code the subprocess emitted two resource warnings.
On Windows with Python 3.12, the complete CPU test suite passed (27 tests, two inference threads) with the pinned llama.cpp build and cached GGUF models. Ruff lint and formatting passed. I also exercised shutdown suppression on CPython 3.11 through 3.14.