-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tasks run too often #3
Comments
MCRON is not suitable for running tasks with millisecond accuracy. Of course, you can increase the accuracy by using the timer_period parameter in the init_timer function. You have to assume that the task start time depends on many factors:
|
Hello fizista, Thank you for your reply. I am not looking for ms accuracy. What i am trying to say is that my task SHOULD run every 10sec, but is now running every ~50-100ms. So the task is running very often. I have commented out all other tasks, so i know this is the only task running. |
As usually the solution was something simple. Documenting here for other: the function run_task() used to be a while True: with a sleep() in it. I removed the sleep() but obviously forgot to remove the while True: at the top of this large(ish) function. So it now works perfectly. |
I seem to be running into a problem with your library. I am running this on an ESP32 and the tasks fire WAY too quickly:
mcron.init_timer()
mcron.insert(mcron.PERIOD_MINUTE, range(0, mcron.PERIOD_MINUTE, 10), 'minute_10s', run_task())
I expect run_task() to run every 10 seconds, but it looks like it runs faster than every 100ms.
I am sure i am misconfiguring something here, but as far as i can see mcron is using the hardware esp timers, so it is not something like the clockspeed.
I hope you can help me. Thank you!
Device board: ESP32
Micropython version: 1.11
The text was updated successfully, but these errors were encountered: