Recurring Timer
Bengt Richter
bokr at oz.net
Sun Mar 30 02:14:17 EST 2003
On Fri, 28 Mar 2003 06:24:20 -0600, Skip Montanaro <skip at pobox.com> wrote:
> boethius> I checked out the Threading.Timer and it executes _once_ after
> boethius> x seconds. I need something similar: a Timer that executes
> boethius> every x seconds until explicitely stoped.
>
> boethius> How can I do this? O:-)
>
>Why not simply restart it as the last thing you do when it executes?
>
Will that result in creeping cumulative errors if what you want is an
exact periodic (with acceptable delay-jitter after due times, but
self-correcting re cumulative delay)?
Otherwise how about checking current wall clock time with time.clock() and
computing a time to sleep 'til the next computed wall clock due time?
Maybe even with some error estimation and compensation for the calculation?
Then just use a flag to indicate timer enabled/disabled and DTRT.
Regards,
Bengt Richter
More information about the Python-list
mailing list