Repository navigation
fix: reconnect camera stream after a drop - #36
deepakpopli wants to merge 1 commit into
Conversation
|
Thanks for contributing to the Cyberwave Python SDK, @deepak61296! Maintainer contacts: @KhushiSharma22. When this PR is ready, we request a maintainer review and run an automated advisory review. CI and human review remain the source of truth. Please describe what changed and how you tested it. See the contribution guide or ask for help on Discord. Drafts are welcome. Merged human contributions receive a Discord thank-you. To opt out, check the PR template's Discord opt-out box or add |
Automated advisory review · ClaudeCommit: The patch refactors BaseVideoStreamer to split start/stop into inner helpers (_start_webrtc, _close_peer_connection) and adds a monitor-task lifecycle. Three concrete defects are visible in the supplied excerpts. 1. The _monitor_connection loop condition for pc==None was changed in a way that creates an infinite busy-spin when pc is None and reconnect_attempt > 0 after a failed reconnect attempt. 2. stop() no longer guards against being called with no running event loop or outside an async context when the monitor task is None, but more critically the busy-poll cancel loop can run forever if the monitor task never transitions to done (e.g., when it is blocked in a non-cancellable await). 3. _handle_start_command now calls _start_webrtc() instead of start(), so when auto_reconnect is True and _handle_start_command is invoked (e.g., via MQTT command), no monitor task is started, leaving drops undetected for the rest of the session.
Coverage: 3 of 3 changed files; patch excerpts only. Generated REST code, lockfiles, notebooks, SVGs, missing patches and files beyond the 40-file / 60,000-character budget are excluded. GitHub may truncate individual patches. |
7be9cd3 to
32bc5a3
Compare
|
Rebased on 0.7.3.
Tested with |
|
@deepak61296 Hi! Some tests are failing here, let me know if you want me to fix these or if you wanna take a quick run through? Happy to proceed with whatever is the most convenient for you. |
|
hi @KhushiSharma22 i'll take a look and fix it. |
What changed and why?
When the WebRTC connection drops, the camera often doesn't come back.
start(), whichcamera.start_streaming()uses, never starts the reconnect monitor.pcis None.Now
start()starts the monitor,stop()cancels it, and a failed retry is tried again. After the first connect,run_with_auto_reconnect()leaves drops to the monitor, so the two don't retry at the same time.Note: with
auto_reconnect=True(the default),start()now reconnects on its own. I kept the 10 try limit. Should it keep retrying until the network is back instead? Happy to change it.How did you test it?
poetry install -E camera, thenpoetry run pytest tests/test_base_video_reconnect_monitor.py -v: 10 passed. They need aiortc from thecameraextra, so they skip in CI.start_streaming()stayed down. With it, the stream came back every time.Contributor checklist
Recognition
Merged human contributions receive a thank-you in the Cyberwave Discord using
the PR title, link, and GitHub username. Discord membership is not required.