TaskManager: comments

This commit is contained in:
Thomas Farstrike
2025-12-12 09:58:34 +01:00
parent 61ae548e4c
commit 658b999929
+7 -3
View File
@@ -9,11 +9,15 @@ class TaskManager:
disabled = False
@classmethod
async def _asyncio_thread(cls, ms_to_sleep):
async def _asyncio_thread(cls, sleep_ms):
print("asyncio_thread started")
while cls.keep_running is True:
#print(f"asyncio_thread tick because {cls.keep_running}")
await asyncio.sleep_ms(ms_to_sleep) # This delay determines how quickly new tasks can be started, so keep it below human reaction speed
#print(f"asyncio_thread tick because cls.keep_running:{cls.keep_running}")
# According to the docs, lv.timer_handler should be called periodically, but everything seems to work fine without it.
# Perhaps lvgl_micropython is doing this somehow, although I can't find it... I guess the task_handler...?
# sleep_ms can't handle too big values, so limit it to 30 ms, which equals 33 fps
# sleep_ms = min(lv.timer_handler(), 30) # lv.timer_handler() will return LV_NO_TIMER_READY (UINT32_MAX) if there are no running timers
await asyncio.sleep_ms(sleep_ms)
print("WARNING: asyncio_thread exited, now asyncio.create_task() won't work anymore")
@classmethod