fix: close stdout/stderr pipes in AcpTransport.close()#83
Open
KuaaMU wants to merge 1 commit intomco-org:mainfrom
Open
fix: close stdout/stderr pipes in AcpTransport.close()#83KuaaMU wants to merge 1 commit intomco-org:mainfrom
KuaaMU wants to merge 1 commit intomco-org:mainfrom
Conversation
AcpTransport.close() closed stdin and called terminate()/wait(), but never closed the stdout (and stderr) pipes opened as subprocess.PIPE. The file descriptor leaked until GC, triggering ResourceWarning when running with -W error::ResourceWarning. Fix: close stdout and stderr before terminate(), following the same try/except pattern used for stdin. Catch both OSError and ValueError to handle concurrent reader thread edge cases. Closes mco-org#82
c369e6e to
f7d608d
Compare
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.
Problem
AcpTransport.close()closesstdinand callsterminate()/wait(), but never closes thestdout(andstderr) pipes opened assubprocess.PIPE. The file descriptor leaks until GC, triggeringResourceWarningwhen running with-W error::ResourceWarning.Solution
Close
stdoutandstderrbeforeterminate(), following the sametry/exceptpattern used forstdin. Catch bothOSErrorandValueErrorto handle concurrent reader thread edge cases.Reference:
runtime/session/manager.pylines 54-57 uses the same cleanup pattern for daemon subprocesses.Verification
All 13 tests pass. Two new tests added:
test_close_no_resource_warning— verifies no ResourceWarning after close() + GCtest_close_no_resource_warning_with_stderr_pipe— verifies stderr PIPE path is also coveredCloses #82