Start running only when task is running

This commit is contained in:
atse 2023-07-07 16:09:03 +08:00
parent 1fd49360d0
commit 84018c3ebc
1 changed files with 2 additions and 1 deletions

View File

@ -36,7 +36,7 @@ class ClientWatcher(QObject):
def __init__(self, parent, client, update_s):
self.update_s = update_s
self.running = True
self.running = False
self.client = client
self.watch_task = None
super().__init__(parent)
@ -52,6 +52,7 @@ 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()