Skip to content

fix: process_video silent hang on callback error#2022

Merged
Borda merged 13 commits intoroboflow:developfrom
realh4m:fix/video-worker-error-propagation
Jan 30, 2026
Merged

fix: process_video silent hang on callback error#2022
Borda merged 13 commits intoroboflow:developfrom
realh4m:fix/video-worker-error-propagation

Conversation

@realh4m
Copy link
Copy Markdown
Contributor

@realh4m realh4m commented Nov 27, 2025

Description

Added exception tracking in process_video so callback errors raised in the worker loop are surfaced after reader/writer threads finish, preventing silent hangs when the callback crashes mid-stream.

Introduced read_finished to avoid draining the read queue unnecessarily once EOF is reached.

  • Issue: Fixes the silent failure where process_video could hang without any error when the callback raised an exception.
  • Dependencies: None.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How has this change been tested, please provide a testcase or example of how you tested the change?

Verified locally with a callback that raises an exception.

Any specific deployment considerations

No additional considerations; behavior change only affects process_video error handling.

Docs

  • Docs updated? What were the changes:

@realh4m realh4m requested a review from SkalskiP as a code owner November 27, 2025 11:03
@realh4m realh4m changed the title Fix process_video silent hang on callback error fix: process_video silent hang on callback error Nov 27, 2025
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Nov 27, 2025

CLA assistant check
All committers have signed the CLA.

@Borda
Copy link
Copy Markdown
Member

Borda commented Jan 15, 2026

@realh4m, thank you for your contribution and suggested fix. Could you also include a test to verify that it resolves the issue? 🦩

@Borda Borda changed the title fix: process_video silent hang on callback error fix: process_video silent hang on callback error Jan 15, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a silent hang issue in process_video when the callback function raises an exception during video processing. The fix ensures that exceptions are caught, the pipeline is properly shut down, and the error is re-raised to the caller.

Changes:

  • Added exception tracking (exception_in_worker) to capture and re-raise callback errors
  • Introduced read_finished flag to conditionally drain the read queue in the finally block
  • Modified the finally block to drain remaining frames from the read queue when an exception occurs, preventing deadlock

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@realh4m realh4m force-pushed the fix/video-worker-error-propagation branch from 0406081 to fce63f8 Compare January 15, 2026 14:31
@realh4m
Copy link
Copy Markdown
Contributor Author

realh4m commented Jan 15, 2026

Thank you for the feedback. I've added unit tests in test/utils/test_video.py to verify that process_video now correctly raises exceptions without hanging. I also included tests for general video utility functions and fixed a minor typo in the process_video docstring. All tests passed successfully.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 16, 2026

Codecov Report

❌ Patch coverage is 79.31034% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 60%. Comparing base (7bf03f5) to head (0830888).
⚠️ Report is 5 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff           @@
##           develop   #2022   +/-   ##
=======================================
+ Coverage       59%     60%   +1%     
=======================================
  Files           61      61           
  Lines         7086    7108   +22     
=======================================
+ Hits          4193    4287   +94     
+ Misses        2893    2821   -72     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SkalskiP
Copy link
Copy Markdown
Collaborator

Hi @realh4m 👋🏻 Thanks a lot for your interest in supervision drafting this PR. I'm actually working on slightly deper rewrite of that whole function, here: #2102.

I want to keep the trace of your contribution so I'll most likely merge my changes into your branch once I'm done, and we will merge it from here.

@realh4m
Copy link
Copy Markdown
Contributor Author

realh4m commented Jan 24, 2026

Sounds good. I'll wait for your updates. Thanks.

@Borda Borda added the bug Something isn't working label Jan 26, 2026
Borda
Borda previously approved these changes Jan 26, 2026
Borda
Borda previously approved these changes Jan 26, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Borda
Copy link
Copy Markdown
Member

Borda commented Jan 26, 2026

@SkalskiP I would be in favor of merging this one as is, since it adds a handful of tests. If you have a better refactor, you can still overwrite/replace it with yours...

Borda
Borda previously approved these changes Jan 26, 2026
@Borda Borda merged commit 3b09a63 into roboflow:develop Jan 30, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants