fix null pointer if closing an interface which was already shutting down

This commit is contained in:
Kevin Hester
2024-07-06 13:43:19 -07:00
parent 42e069455e
commit 4c02114b75

View File

@@ -67,9 +67,10 @@ class SerialInterface(StreamInterface):
def close(self):
"""Close a connection to the device"""
self.stream.flush()
time.sleep(0.1)
self.stream.flush()
time.sleep(0.1)
if self.stream: # Stream can be null if we were already closed
self.stream.flush() # FIXME: why are there these two flushes with 100ms sleeps? This shouldn't be necessary
time.sleep(0.1)
self.stream.flush()
time.sleep(0.1)
logging.debug("Closing Serial stream")
StreamInterface.close(self)