> On 3 Feb 2022, at 04:45, Cecil Westerhof via Python-list 
> <python-list@python.org> wrote:
> 
> Have to be careful that timing keeps correct when target takes a 'lot'
> of time.
> Something to ponder about, but can wait.

You have noticed that your class does call the function at the repeat interval 
but
rather at the repeat interval plus processing time.

The way to fix this is to subtract the last processing elapsed time for the 
next interval.
Sort of a software phase locked loop.

Just before you call the run function record the time.time() as start_time.
Then you can calculate next_interval = max( .001, interval - time.time() - 
start_time)
I use 1ms as the min interval.

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to