Repository navigation
fix(foundation): close the input when the Extractor constructor raises (#2100) - #2106
Merged
Merged
Conversation
#2100) Only a KeyboardInterrupt reached _cleanup, so a FormatError out of __init__ left an input the Extractor opened open until collection, which Windows will not delete. The magic read and run() now release an owned input and detach its finaliser on any exception; a caller's stream stays open. _cleanup itself is not called: an unknown format raises before any engine exists.
Owner
Author
|
GOOD TO GO at
|
Contributor
|
Coverage: 91.54% (unit tier, Python 3.15,
Per-file detail: the |
Owner
Author
|
Ready to merge at
This closes #2100. #2107 (closing the engine too) follows once it merges. |
4 of 5 tasks
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.
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
fix— bug fixesDescription of your pull request and other information
Closes #2100. When an engine raised out of
Extractor.__init__→run→record_frames, for example aFormatErroron a packet block before any interface, onlyKeyboardInterruptcleaned up. An input the Extractor had opened stayed open until GC, and on Windows that blocks deleting the file (WinError 32)._cleanup(), as the issue proposed: for an unknown magic number,run()raises before_exengexists, so_cleanup()would mask theFormatErrorwith anAttributeError. It would also close a half-started engine and end a flow trace that never ran.run()sit in atrythat, on any exception, closes the input only if the Extractor owns it (the Extractor._cleanup closes the caller-supplied stream and leaks the file it opened itself #610 rule), detaches the finaliser, and re-raises. A second call is harmless.test_extraction_constructor_raises_2100_unitrecords the handles the Extractor opens. Without the fix, the packet-block-before-interface case leaves its file open. It also pins that the unknown-format error is not masked and that a caller's file or stream stays open.test_extraction_ownershippasses.