Fix reolink patrol#360
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #360 +/- ##
===========================================
- Coverage 73.85% 72.74% -1.11%
===========================================
Files 6 6
Lines 631 631
===========================================
- Hits 466 459 -7
- Misses 165 172 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fe51
left a comment
There was a problem hiding this comment.
Thanks a lot for the PR, seems mainly fine, but one quesiton
stuck_check_loop runs in a separate thread from patrol_loop, and both access cam.last_images concurrently.
stuck_check_loop runs in a separate thread from patrol_loop, and both access cam.last_images concurrently. The cam.last_images.clear() call after a reboot (stuck_detector.py line 166) can race with the patrol loop iterating the same dict and raise RuntimeError: dictionary changed size during iteration. Would it be safe to replace clear() with resetting only the known pose keys, or add a small lock shared with the patrol loop?
=> I am not mastering threading but I spot this potentiel conflit -> What do you think ? Would it be an issue ?
| ) | ||
| if stuck_detector_enabled and getattr(cam, "cam_type", "static") == "ptz" and hasattr(cam, "reboot_camera"): | ||
| stuck_flag = threading.Event() | ||
| stuck_thread = threading.Thread(target=stuck_check_loop, args=(cam_id, stuck_flag), daemon=True) |
There was a problem hiding this comment.
Minor naming question: stuck_check_loop calls its first argument camera_ip, but main.py passes cam_id to it (the CAMERA_REGISTRY loop variable). Since CAMERA_REGISTRY is keyed by IP here the name is technically correct, but renaming the parameter to cam_id in stuck_detector.py would align with main.py and patrol.py conventions.
what do you think ?
The Reolink cameras regularly freeze. To avoid this issue, we propose regularly checking whether the camera poses are changing. If they are not, we reboot the camera