Fixed negative sleep_time error

This commit is contained in:
Maximilian Giller 2019-03-24 21:35:05 +01:00
parent 94591ec51e
commit 319e6947b1

View file

@ -1,5 +1,7 @@
from datetime import datetime, timedelta
min_sleep_minutes = 0
class LoopTimer (object):
"""Manages loop times and sleeps until
next loop."""
@ -36,6 +38,9 @@ class LoopTimer(object):
time_until_hour = self.get_time_to_next_hour()
if time_until_hour < sleep_time:
return time_until_hour
if sleep_time < timedelta(0):
sleep_time = timedelta(0, 0, 0, 0, min_sleep_minutes)
return sleep_time
def get_last_duration (self):