I'm trying to set up Clock.schedule_interval using Kivy in Python.
The relevant code snippet looks something like this:
event = Clock.schedule_interval(lambda x: refresh(),20)
The refresh function usually takes approx 10 seconds to run, but occasionally it will take 60 seconds.
I want the 20 second wait to occur between each iteration of refresh.
That is, I'd like it to work like this:
- Refresh. Wait for it to complete (approx 10-60 seconds).
- After completion, wait 20 seconds.
- Refresh again. Etc.
It seems like the default behavior is to start the 20 second timer when refresh starts, not when it completes. Is there a way to change this?
Also, if refresh is taking 60s and the 20s interval passes, will it start refresh a second time even though refresh is ongoing? Will it queue another thread? If so, is there a way to tell it "If refresh hasn't completed yet, skip this iteration and wait another interval"?
Thanks for any help you can offer!