Skip to content

Commit 4c02114

Browse files
committed
fix null pointer if closing an interface which was already shutting down
1 parent 42e0694 commit 4c02114

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

meshtastic/serial_interface.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ def __init__(self, devPath: Optional[str]=None, debugOut=None, noProto=False, co
6767

6868
def close(self):
6969
"""Close a connection to the device"""
70-
self.stream.flush()
71-
time.sleep(0.1)
72-
self.stream.flush()
73-
time.sleep(0.1)
70+
if self.stream: # Stream can be null if we were already closed
71+
self.stream.flush() # FIXME: why are there these two flushes with 100ms sleeps? This shouldn't be necessary
72+
time.sleep(0.1)
73+
self.stream.flush()
74+
time.sleep(0.1)
7475
logging.debug("Closing Serial stream")
7576
StreamInterface.close(self)

0 commit comments

Comments
 (0)