Skip to content

Fix/rvc2 poe tests#1815

Merged
aljazdu merged 3 commits into
developfrom
fix/rvc2_poe_tests
May 26, 2026
Merged

Fix/rvc2 poe tests#1815
aljazdu merged 3 commits into
developfrom
fix/rvc2_poe_tests

Conversation

@aljazdu

@aljazdu aljazdu commented May 26, 2026

Copy link
Copy Markdown
Contributor

Purpose

Adding signal handlers to certain tests, thereby fixing the issue with unclean exit.

Specification

None / not applicable

Dependencies & Potential Impact

None / not applicable

Deployment Plan

None / not applicable

Testing & Validation

None / not applicable

AI Usage

Assisted-by: /

Submitted code was reviewed by a human: YES

The author is taking the responsibility for the contribution: YES

Summary by CodeRabbit

Release Notes

  • Enhancements
    • C++ example programs for neural network processing and benchmarking now support graceful shutdown when interrupted by user signals, ensuring pipelines are properly terminated and system resources are cleanly released before program exit.

Review Change Stack

@aljazdu aljazdu requested a review from moratom May 26, 2026 05:35
@aljazdu aljazdu self-assigned this May 26, 2026
@aljazdu aljazdu added the testable PR is ready to be tested - run vanilla tests label May 26, 2026
@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Four C++ example files in DepthAI add graceful shutdown support via POSIX signals. Each file introduces an atomic quit flag, signal handler registration, and updates the main processing loop to exit cleanly when interrupted by SIGTERM or SIGINT, followed by explicit pipeline stop and wait calls.

Changes

Graceful shutdown via signal handling in C++ examples

Layer / File(s) Summary
Signal handler infrastructure setup
examples/cpp/Benchmark/benchmark_nn.cpp, examples/cpp/NeuralNetwork/neural_network.cpp, examples/cpp/NeuralNetwork/neural_network_multi_input.cpp, examples/cpp/NeuralNetwork/neural_network_multi_input_combined.cpp
Each example adds a global std::atomic<bool> quitEvent flag, implements a signalHandler() function that sets the flag on SIGTERM/SIGINT, and registers the handler at main() startup.
Loop exit condition and pipeline shutdown
examples/cpp/Benchmark/benchmark_nn.cpp, examples/cpp/NeuralNetwork/neural_network.cpp, examples/cpp/NeuralNetwork/neural_network_multi_input.cpp, examples/cpp/NeuralNetwork/neural_network_multi_input_combined.cpp
Each example updates the main loop condition to exit when quitEvent is set, and adds explicit pipeline.stop() followed by pipeline.wait() after the loop to ensure clean pipeline termination.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • luxonis/depthai-core#1786: Both PRs add POSIX signal-based graceful shutdown by introducing a std::atomic<bool> quitEvent/signalHandler and updating the example main processing loop to exit (and cleanly stop the pipeline) when quitEvent is set.

Suggested reviewers

  • moratom

Poem

🐰 A graceful farewell, when signals call,
The loops now heed, no crash at all!
With atoms true and handlers keen,
The cleanest shutdown ever seen—
SIGTERM sets the flag so bright,
And stop() waits the pipelined night! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The PR title 'Fix/rvc2 poe tests' is vague and generic. It uses abbreviated terminology (rvc2, poe) without context and doesn't clearly convey that the changes add signal handlers for graceful shutdown in neural network examples. Use a more descriptive title that clearly indicates the main change, such as 'Add signal handlers for graceful shutdown in neural network examples' or 'Fix unclean exit in RVC2 POE tests with signal handlers'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/rvc2_poe_tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@examples/cpp/Benchmark/benchmark_nn.cpp`:
- Around line 1-2: The program uses std::atomic<bool> quitEvent from a signal
handler which is not guaranteed signal-safe; change the communication to use a
signal-safe flag: declare quitEvent as volatile std::sig_atomic_t and have the
signal handler store 1 into quitEvent, then check quitEvent != 0 in the main
loop to break; alternatively, if you must keep std::atomic<bool>, gate it with a
compile-time/runtime lock-free check (std::atomic<bool>::is_always_lock_free or
is_lock_free) and assert/fallback if not lock-free. Ensure all references to
quitEvent and the signal handler are updated consistently (set in handler, read
in loop) and avoid non-signal-safe operations inside the handler.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 39aadeb1-2904-43d8-9a67-123a079027f5

📥 Commits

Reviewing files that changed from the base of the PR and between b83a86e and e993481.

📒 Files selected for processing (4)
  • examples/cpp/Benchmark/benchmark_nn.cpp
  • examples/cpp/NeuralNetwork/neural_network.cpp
  • examples/cpp/NeuralNetwork/neural_network_multi_input.cpp
  • examples/cpp/NeuralNetwork/neural_network_multi_input_combined.cpp
📜 Review details
🧰 Additional context used
🪛 Cppcheck (2.20.0)
examples/cpp/NeuralNetwork/neural_network_multi_input_combined.cpp

[error] 18-18: There is an unknown macro here somewhere. Configuration is required. If DEPTHAI_NLOHMANN_DEFINE_TYPE_INTRUSIVE is a macro then please configure it.

(unknownMacro)

examples/cpp/NeuralNetwork/neural_network_multi_input.cpp

[error] 18-18: There is an unknown macro here somewhere. Configuration is required. If DEPTHAI_NLOHMANN_DEFINE_TYPE_INTRUSIVE is a macro then please configure it.

(unknownMacro)

🔇 Additional comments (7)
examples/cpp/NeuralNetwork/neural_network.cpp (2)

1-2: Duplicate: same signal-handler flag safety issue as in benchmark_nn.cpp.

Please apply the same std::sig_atomic_t fix pattern here.

Also applies to: 8-12, 43-43


15-16: LGTM!

Also applies to: 49-50

examples/cpp/NeuralNetwork/neural_network_multi_input.cpp (2)

1-2: Duplicate: same signal-handler flag safety issue as in benchmark_nn.cpp.

Please apply the same std::sig_atomic_t fix pattern here.

Also applies to: 10-14, 62-62


17-18: LGTM!

Also applies to: 82-83

examples/cpp/NeuralNetwork/neural_network_multi_input_combined.cpp (2)

1-2: Duplicate: same signal-handler flag safety issue as in benchmark_nn.cpp.

Please apply the same std::sig_atomic_t fix pattern here.

Also applies to: 10-14, 64-64


17-18: LGTM!

Also applies to: 85-86

examples/cpp/Benchmark/benchmark_nn.cpp (1)

14-15: LGTM!

Also applies to: 69-70

Comment thread examples/cpp/Benchmark/benchmark_nn.cpp
@aljazdu aljazdu merged commit 5fe9eaa into develop May 26, 2026
81 of 140 checks passed
@aljazdu aljazdu deleted the fix/rvc2_poe_tests branch May 26, 2026 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testable PR is ready to be tested - run vanilla tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants