Skip to content

Commit dbc0101

Browse files
committed
Wrap double-close in a try-catch. Slightly ugly but oh well.
1 parent debbb8c commit dbc0101

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

meshtastic/stream_interface.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,12 @@ def _disconnected(self) -> None:
9393

9494
logger.debug("Closing our port")
9595
# pylint: disable=E0203
96-
if not self.stream is None:
96+
if hasattr(self, "stream") and self.stream is not None and getattr(self.stream, "is_open", False):
9797
# pylint: disable=E0203
98-
self.stream.close()
98+
try:
99+
self.stream.close()
100+
except Exception as e:
101+
logger.debug(f"Exception during close: {e}")
99102
# pylint: disable=W0201
100103
self.stream = None
101104

0 commit comments

Comments
 (0)