Search code examples
pythontimewin64ctime

With python: intervals at x:00 repeat


How do I sched a repeat timer for 5 min intervals. Which fire at 00 seconds, then repeat at 00. Ok, not hard real-time but as close as possible with sys lags. Trying to avoid a build up in lags and get near 00.

Lang: Python, OS: WinXP x64

System has 25ms resolution.

Any code would be helpful, tia


Solution

  • I don't know how to do it any more accurately than with threading.Timer. It's "one-shot", but that just means the function you schedule that way must immediately re-schedule itself for another 300 seconds later, first thing. (You can add accuracy by measuring the exact time with time.time each time and varying the next scheduling delay accordingly).