Stop polling drift

Just waiting for the update_s doesn't take into account the time to
execute update_params, and causes time drift.
This commit is contained in:
atse 2023-08-08 17:16:11 +08:00 committed by Egor Savkin
parent 7dd5d15047
commit 400f3a98e8
1 changed files with 3 additions and 1 deletions

View File

@ -49,9 +49,11 @@ class ClientWatcher(QObject):
super().__init__(parent)
async def run(self):
loop = asyncio.get_running_loop()
while self.running:
time = loop.time()
await self.update_params()
await asyncio.sleep(self.update_s)
await asyncio.sleep(self.update_s - (loop.time() - time))
async def update_params(self):
self.fan_update.emit(await tec_client.fan())