Improved periodical to forgive skipped beats
This commit is contained in:
parent
7a61f60ecc
commit
9fc8db577a
1 changed files with 6 additions and 1 deletions
|
@ -307,8 +307,13 @@ class Periodical:
|
|||
now = time.time()
|
||||
|
||||
if (now - self.prev) >= self.interval:
|
||||
self.prev += self.interval
|
||||
skipped, overshoot = divmod(now - self.prev, self.interval)
|
||||
skipped -= 1
|
||||
if skipped:
|
||||
log("Skipped:", skipped, overshoot, now - self.prev, self.interval)
|
||||
self.prev = now - overshoot
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue