Force-release camera/serial resources when a device disconnect fails#47
Open
nobullryder wants to merge 1 commit into
Open
Force-release camera/serial resources when a device disconnect fails#47nobullryder wants to merge 1 commit into
nobullryder wants to merge 1 commit into
Conversation
When LeRobot's device.disconnect() throws (a flaky USB camera or serial port), the underlying handle can stay open — which keeps the camera busy and blocks the next teleop/record/calibrate run from acquiring it. Add safe_disconnect_device(): attempt the normal disconnect, and on failure best-effort force-close the serial/camera resources so the device is actually released. Wire it into teleoperation's teardown; other call sites (calibration, recording) can adopt the same helper in follow-ups. Tests in tests/test_devices.py cover the success path and the disconnect-fails-then-force-release path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When LeRobot's
device.disconnect()throws (a flaky USB camera or serial port), the underlying handle can stay open — which keeps the camera busy and blocks the next teleop / record / calibrate run from acquiring it.What this does
safe_disconnect_device()attempts the normal disconnect, and on failure best-effort force-closes the serial/camera resources so the device is actually released. It's wired into teleoperation's teardown here; calibration and recording can adopt the same helper in follow-ups.Tests
tests/test_devices.pycovers the success path and the disconnect-fails-then-force-release path.🤖 Generated with Claude Code