diff options
-rw-r--r-- | pyload/AddonManager.py | 3 | ||||
-rw-r--r-- | pyload/plugins/Addon.py | 22 |
2 files changed, 18 insertions, 7 deletions
diff --git a/pyload/AddonManager.py b/pyload/AddonManager.py index 75ff4ebc9..682fdc780 100644 --- a/pyload/AddonManager.py +++ b/pyload/AddonManager.py @@ -140,7 +140,8 @@ class AddonManager: self.log.debug("Plugin deactivated: %s" % plugin) #remove periodic call - self.log.debug("Removed callback %s" % self.core.scheduler.removeJob(addon.cb)) + if addon.cb: + self.log.debug("Removed callback %s" % self.core.scheduler.removeJob(addon.cb)) del self.plugins[addon.__name__] #remove event listener diff --git a/pyload/plugins/Addon.py b/pyload/plugins/Addon.py index ee8cbe62c..50a38960a 100644 --- a/pyload/plugins/Addon.py +++ b/pyload/plugins/Addon.py @@ -78,7 +78,7 @@ class Addon(Base): event_map = None #: periodic call interval in seconds - interval = 60 + interval = 30 def __init__(self, core, manager, user=None): Base.__init__(self, core, user) @@ -104,12 +104,21 @@ class Addon(Base): #delete for various reasons self.event_map = None - self.initPeriodical() + #self.initPeriodical() self.init() - def initPeriodical(self): - if self.interval >=1: - self.cb = self.core.scheduler.addJob(0, self._periodical, threaded=False) + def stopPeriodical(self): + if not self.cb: + return + r = self.core.scheduler.removeJob(self.cb) + 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) + else: + self.stopPeriodical() def _periodical(self): try: @@ -119,7 +128,8 @@ class Addon(Base): if self.core.debug: print_exc() - self.cb = self.core.scheduler.addJob(self.interval, self._periodical, threaded=False) + if self.cb: + self.cb = self.core.scheduler.addJob(self.interval, self._periodical, threaded=False) def __repr__(self): return "<Addon %s>" % self.__name__ |