Skip to content
Snippets Groups Projects
Commit c71d9672 authored by Andreas Gattringer's avatar Andreas Gattringer
Browse files

updated period task logic

parent aa4b0a59
No related branches found
No related tags found
No related merge requests found
......@@ -18,10 +18,13 @@ class PeriodicTask:
self._call_back = async_call_back
async def run(self):
start_time = time.ticks_ms()
last = start_time
func = self._function
args = self._args
call_back = self._call_back
delay_seconds = 25 / 1000
while True:
last = time.time()
print("A0", args)
......@@ -32,7 +35,9 @@ class PeriodicTask:
await call_back(result)
while True:
now = time.time()
if now - last > 0:
now = time.ticks_ms()
diff = time.ticks_diff(last, now)
if diff > self._every_ms:
last = now
break
await asyncio.sleep(delay_seconds)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment