[core] Switch update interval parameter to seconds
As correctly pointed out by @rrhuffy, restricting update intervals to minutes is pretty arbitrary. Therefore, change logic to specify updates intervals in *seconds*. Also, to maintain backwards compatibility for users that already have custom intervals in their config, allow a module to specify their own "factor" for intervals. So a module that expects the interval to be in minutes can set the factor to 60.
This commit is contained in:
parent
45e7574ef8
commit
621564d247
7 changed files with 11 additions and 1 deletions
|
@ -41,6 +41,7 @@ class Module(object):
|
|||
self.error = None
|
||||
self._next = int(time.time())
|
||||
self._default_interval = 0
|
||||
self._interval_factor = 1
|
||||
self._engine = engine
|
||||
|
||||
self._configFile = None
|
||||
|
@ -99,7 +100,10 @@ class Module(object):
|
|||
except Exception as e:
|
||||
log.error("error updating '{}': {}".format(self.name, str(e)))
|
||||
self.error = str(e)
|
||||
self._next += int(self.parameter("interval", self._default_interval))*60
|
||||
self._next += int(self.parameter("interval", self._default_interval))*self._interval_factor
|
||||
|
||||
def interval_factor(self, factor):
|
||||
self._interval_factor = factor
|
||||
|
||||
def interval(self, intvl):
|
||||
self._default_interval = intvl
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue