Gracefully handle errors when binding SocketCAN fails by acolomb · Pull Request #1771 · hardbyte/python-can

@acolomb

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

@acolomb marked this pull request as ready for review

April 25, 2024 07:37

hardbyte

@acolomb

@acolomb acolomb deleted the socketcan-shutdown-on-socket-error branch

June 18, 2024 08:34