fix(dm_driver): join control thread before closing CAN bus on shutdown - #86
Open
jbohg wants to merge 1 commit into
Open
fix(dm_driver): join control thread before closing CAN bus on shutdown#86jbohg wants to merge 1 commit into
jbohg wants to merge 1 commit into
Conversation
Save the control loop thread as self._control_thread and join it (up to 2 s) in close() before calling motor_interface.close(). Without this, bus.shutdown() races the still-running control loop, causing a 'file descriptor cannot be a negative integer (-1)' error on exit. Co-Authored-By: Claude Sonnet 4.6 <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
close()setsself.running = Falsethen immediately callsmotor_interface.close()/bus.shutdown()without waiting for the control loop thread to exit. The thread is still mid-iteration when the socket is torn down, causing:ValueError: file descriptor cannot be a negative integer (-1)Fix
self._control_threadinstart_thread()close(), join the thread (up to 2 s) before callingmotor_interface.close()