Avoid creating log files when no serial device is connected
This commit is contained in:
@@ -158,7 +158,6 @@ class SerialBridge(threading.Thread):
|
||||
self._log_file.write(f"{ts} {line}\n")
|
||||
|
||||
def run(self) -> None:
|
||||
self._open_log()
|
||||
try:
|
||||
while not self._stop_event.is_set():
|
||||
if self._serial is None:
|
||||
@@ -180,6 +179,7 @@ class SerialBridge(threading.Thread):
|
||||
except Exception as exc:
|
||||
self.broadcaster.publish(f"[bridge] disconnected: {exc}")
|
||||
self._close_serial()
|
||||
self._close_log()
|
||||
time.sleep(2)
|
||||
finally:
|
||||
self._close_serial()
|
||||
|
||||
Reference in New Issue
Block a user