diff options
author | Walter Purcaro <vuolter@gmail.com> | 2013-09-15 23:21:18 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2013-11-16 17:40:12 +0100 |
commit | 69e59eca82a72c7a6ab06d92bfc7d1209e5ab1d4 (patch) | |
tree | 354bad1a6d7d772ab4669eef2b83f321f1227e69 /pyload/plugins | |
parent | typo (diff) | |
download | pyload-69e59eca82a72c7a6ab06d92bfc7d1209e5ab1d4.tar.xz |
startPeriodical + setInterval methods
Diffstat (limited to 'pyload/plugins')
-rw-r--r-- | pyload/plugins/Addon.py | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/pyload/plugins/Addon.py b/pyload/plugins/Addon.py index 85ae20e09..30442423d 100644 --- a/pyload/plugins/Addon.py +++ b/pyload/plugins/Addon.py @@ -104,21 +104,33 @@ class Addon(Base): #delete for various reasons self.event_map = None - #self.initPeriodical() + #self.startPeriodical() self.init() + def startPeriodical(self, interval=self.interval, wait=0): + if self.cb or not self.setInterval(interval): + return False + else: + self.cb = self.core.scheduler.addJob(wait, self._periodical, threaded=False) + return interval + def stopPeriodical(self): if not self.cb: - return + return False r = self.core.scheduler.removeJob(self.cb) - self.cb = None + if r: + self.cb = None return r #: return True if successfully removed else False - def initPeriodical(self, wait=0): - if self.interval > 0: - self.cb = self.core.scheduler.addJob(wait, self._periodical, threaded=False) + def setInterval(self, interval, reset=False): + if interval > 0: + if reset: + return self.stopPeriodical() and self.startPeriodical(interval) + else: + self.interval = interval + return True else: - self.stopPeriodical() + return False def _periodical(self): try: |