Gracefully handle errors when binding SocketCAN fails by acolomb · Pull Request #1771 · hardbyte/python-can
The parent class BusABC expects to be shutdown properly, checked via its self._is_shutdown flag during object deletion. But that flag is only set when the base class shutdown() is called, which doesn't happen if instantiation of the concrete class failed in can.Bus(). So there is no way to avoid the warning message "SocketcanBus was not properly shut down" if the constructor raised an exception. This change addresses that issue for the SocketCAN interface, by catching an OSError exception in bind_socket(), logging it, and calling self.shutdown().
This was referenced
Apr 24, 2024
marked this pull request as ready for review
acolomb
deleted the
socketcan-shutdown-on-socket-error
branch
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