diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 4fd3ff5..8a9f884 100644 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -36,14 +36,13 @@ class ClientWatcher(QObject): def __init__(self, parent, client, update_s): self.update_s = update_s - self.running = False self.client = client self.watch_task = None super().__init__(parent) async def run(self): loop = asyncio.get_running_loop() - while self.running: + while True: time = loop.time() await self.update_params() await asyncio.sleep(self.update_s - (loop.time() - time)) @@ -52,12 +51,10 @@ class ClientWatcher(QObject): self.fan_update.emit(await self.client.fan()) def start_watching(self): - self.running = True self.watch_task = asyncio.create_task(self.run()) @pyqtSlot() def stop_watching(self): - self.running = False self.watch_task.cancel() @pyqtSlot(float)