some fixes

This commit is contained in:
Ayzen
2026-06-05 14:40:10 +03:00
parent 22942d9dc9
commit bbea744459
35 changed files with 1797 additions and 297 deletions
+17 -6
View File
@@ -86,12 +86,23 @@ class ControlButtonWatcher(QObject):
def start(self) -> None:
"""Open the GPIO line and begin watching for presses on a background thread."""
self._line.open()
self._stop_read_fd, self._stop_write_fd = os.pipe()
self._thread = threading.Thread(
target=self._run, name="control-button-watcher", daemon=True
)
self._thread.start()
# Guard against double-start: a second start would leak the first line/pipe/thread.
if self._thread is not None:
return
try:
self._line.open()
self._stop_read_fd, self._stop_write_fd = os.pipe()
self._thread = threading.Thread(
target=self._run, name="control-button-watcher", daemon=True
)
self._thread.start()
except Exception:
# Release any line/pipe fds opened before the failure so nothing leaks
# and no orphaned thread survives a partial start.
self._thread = None
self._close_stop_pipe()
self._line.close()
raise
def stop(self) -> None:
"""Signal the watcher thread to exit and release the GPIO line and pipe."""