Skip to content

Fix temporary file cleanup in load_video - #14995

Open
SrijanRoy123-github wants to merge 2 commits into
huggingface:mainfrom
SrijanRoy123-github:fix-load-video-tempfile-cleanup-14994
Open

SrijanRoy123-github wants to merge 2 commits into
huggingface:mainfrom
SrijanRoy123-github:fix-load-video-tempfile-cleanup-14994

Conversation

@SrijanRoy123-github

Copy link
Copy Markdown

Summary

Fixes a temporary-file leak in load_video() when downloading or decoding remote videos fails.

Previously, downloaded files were removed only after successful decoding. Exceptions raised during downloading or decoding could bypass cleanup, leaving temporary files on disk.

Changes

  • Ensure temporary files are removed through exception-safe try/finally cleanup.
  • Explicitly close temporary-file and GIF decoder handles, preventing file-locking errors on Windows.
  • Preserve existing exception propagation and local-file behavior.
  • Add regression tests covering successful downloads, corrupted GIFs, interrupted downloads, and local-file preservation.

Testing

Validated locally on Windows using CPU-only tests with mocked HTTP responses.

python -m pytest -q tests/others/test_loading_utils.py

4 passed in 0.08s

Additionally, git diff --check completed without errors.

Fixes #14994

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

load_video() leaks temporary files when remote video decoding fails

1 participant