Repository navigation
FIX: clean up temporary frame files when video scoring is cancelled - #3806
Closed
Kratos (wanjinhao1) wants to merge 1 commit into
Closed
Kratos (wanjinhao1) wants to merge 1 commit into
Kratos (wanjinhao1) wants to merge 1 commit into
Conversation
Author
|
@microsoft-github-policy-service agree |
Contributor
|
Thanks for working on this. #3756 was opened first, and I compared the current heads before closing this duplicate. I did not find behavior here that #3756 lacks. The earlier PR also handles partially created files when extraction itself fails and has broader regression coverage for failed encoding/writes and repeated cancellation. The one useful additional check here is the explicit assertion that the source video still exists after cancellation. I noted that on the now-merged #3756 as a possible small follow-up test. I am closing this PR so we keep one implementation for #3700. Thank you again for the contribution. |
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.
Description
Fixes #3700.
VideoHelper._score_frames_asyncawaitedasyncio.to_thread(self._extract_frames, ...)directly. When the caller was cancelled during extraction, the extraction thread kept running and the temporary frame files it writes (delete=Falsein_extract_frames) were never returned, scored, or cleaned up — one leaked file per sampled frame on every cancelled video scoring.This PR adds
_extract_frames_async, which mirrors the existing audio-extraction pattern (_extract_video_audio_async): it runs extraction throughrun_legacy_sync_asyncso that on cancellation it waits for the extraction thread to finish, then unlinks every temporary frame file before propagatingCancelledError. The video source file is never touched.Tests and Documentation
test_video_frame_scorer_cancellation_during_extraction_async(parametrized over single/double cancel), modeled on the existing audio-cancellation test: it blocks frame extraction on a threading event, cancels the scoring task, releases extraction, and asserts all temporary frame files are removed while the source video survives.python -m pytest tests/unit/score/test_video_scorer.py -q→ 34 passed.No documentation changes needed (internal cleanup behavior).
AI assistance disclosure: this change was implemented with the help of an AI coding agent, on behalf of the PR author wanjinhao1.