events: now support timedelta instead of int/float

This commit is contained in:
nemunaire 2018-01-04 18:16:47 +01:00
parent f520c67c89
commit 4275009dea

View file

@ -63,8 +63,14 @@ class ModuleEvent:
self.call_data = func_data self.call_data = func_data
# Store times # Store times
self.offset = timedelta(seconds=offset) # Time to wait before the first check if isinstance(offset, timedelta):
self.interval = timedelta(seconds=interval) self.offset = offset # Time to wait before the first check
else:
self.offset = timedelta(seconds=offset) # Time to wait before the first check
if isinstance(interval, timedelta):
self.interval = interval
else:
self.interval = timedelta(seconds=interval)
self._end = None # Cache self._end = None # Cache
# How many times do this event? # How many times do this event?