From dbc0101a7a4c97efbdd9efab9178d8e24f03a5b2 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Mon, 10 Nov 2025 13:58:12 -0700 Subject: [PATCH] Wrap double-close in a try-catch. Slightly ugly but oh well. --- meshtastic/stream_interface.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/meshtastic/stream_interface.py b/meshtastic/stream_interface.py index 06ee28a..82b6ab5 100644 --- a/meshtastic/stream_interface.py +++ b/meshtastic/stream_interface.py @@ -93,9 +93,12 @@ class StreamInterface(MeshInterface): logger.debug("Closing our port") # pylint: disable=E0203 - if not self.stream is None: + if hasattr(self, "stream") and self.stream is not None and getattr(self.stream, "is_open", False): # pylint: disable=E0203 - self.stream.close() + try: + self.stream.close() + except Exception as e: + logger.debug(f"Exception during close: {e}") # pylint: disable=W0201 self.stream = None