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 72.74% 72.74%
========================================
Files 6 6
Lines 631 631
========================================
Hits 459 459
Misses 172 172
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 ?
There was a problem hiding this comment.
Good point. I’d rather avoid renaming only stuck_detector.py in this PR: in pyro-engine, cam_id means the camera-pose identifier ("{ip}_{p}"), while here we are passing the CAMERA_REGISTRY key, which is the camera IP. So the cleaner fix would actually be to rename the cam_id loop variable in main.py to camera_ip, and possibly harmonize similar cases elsewhere. I’ll open a follow-up issue for that cleanup instead of expanding this PR scope
# Conflicts: # pyro_camera_api/pyro_camera_api/camera/registry.py
|
Hi @fe51 Good catch ! The real race is in Fixed in 5558279: I now read by known pose key ( |
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