Skip to content

Commit a779b91

Browse files
author
TJ Bruno
committed
Wrap del in try except
1 parent a598559 commit a779b91

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

can/bus.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,14 @@ def __exit__(self, exc_type, exc_val, exc_tb):
437437
self.shutdown()
438438

439439
def __del__(self) -> None:
440-
if not self._is_shutdown:
441-
# We do some best-effort cleanup if the user forgot to properly close the bus instance
442-
self.shutdown()
443-
LOG.warning("%s was not properly shut down", self.__class__)
440+
try:
441+
if not self._is_shutdown:
442+
# We do some best-effort cleanup if the user forgot to properly close the bus instance
443+
self.shutdown()
444+
LOG.warning("%s was not properly shut down", self.__class__)
445+
except Exception as e:
446+
# Prevent unwanted output from being printed to stdout/stderr
447+
LOG.debug(e)
444448

445449
@property
446450
def state(self) -> BusState:

0 commit comments

Comments
 (0)