Fix/rvc2 poe tests#1815
Conversation
📝 WalkthroughWalkthroughFour 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. ChangesGraceful shutdown via signal handling in C++ examples
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (4)
examples/cpp/Benchmark/benchmark_nn.cppexamples/cpp/NeuralNetwork/neural_network.cppexamples/cpp/NeuralNetwork/neural_network_multi_input.cppexamples/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 inbenchmark_nn.cpp.Please apply the same
std::sig_atomic_tfix 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 inbenchmark_nn.cpp.Please apply the same
std::sig_atomic_tfix 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 inbenchmark_nn.cpp.Please apply the same
std::sig_atomic_tfix 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
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