summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2011-01-25 22:41:17 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2011-01-25 22:41:17 +0100
commit7a9f05ecc3f1020dfd5fbc4b9f8c1242c88877f5 (patch)
tree2abe89a7667a1f52df8df3b6e6d4cb02831d69d2
parentfixed gui progress issue (diff)
downloadpyload-7a9f05ecc3f1020dfd5fbc4b9f8c1242c88877f5.tar.xz
moved hooks periodical call to scheduler
-rw-r--r--module/HookManager.py23
-rw-r--r--module/plugins/Hook.py1
-rwxr-xr-xpyLoadCore.py1
3 files changed, 17 insertions, 8 deletions
diff --git a/module/HookManager.py b/module/HookManager.py
index a6a8e4005..69e922d14 100644
--- a/module/HookManager.py
+++ b/module/HookManager.py
@@ -48,7 +48,8 @@ class HookManager():
return func(*args)
except Exception, e:
args[0].log.error(_("Error executing hooks: %s") % str(e))
- traceback.print_exc()
+ if args[0].core.debug:
+ traceback.print_exc()
return new
def createIndex(self):
@@ -70,12 +71,21 @@ class HookManager():
self.plugins = plugins
- @try_catch
- def periodical(self):
- for plugin in self.plugins:
- if plugin.isActivated() and plugin.lastCall + plugin.interval < time():
- plugin.lastCall = time()
+ def initPeriodical(self):
+ def wrapPeriodical(plugin):
+ plugin.lastCall = time()
+ try:
plugin.periodical()
+ except Exception, e:
+ args[0].log.error(_("Error executing hooks: %s") % str(e))
+ if self.core.debug:
+ traceback.print_exc()
+
+ self.core.scheduler.addJob(plugin.interval, wrapPeriodical, args=[plugin])
+
+ for plugin in self.plugins:
+ if plugin.isActivated():
+ self.core.scheduler.addJob(0, wrapPeriodical, args=[plugin])
@try_catch
@@ -83,6 +93,7 @@ class HookManager():
for plugin in self.plugins:
if plugin.isActivated():
plugin.coreReady()
+ self.initPeriodical()
@lock
def downloadStarts(self, pyfile):
diff --git a/module/plugins/Hook.py b/module/plugins/Hook.py
index 93454b131..1b3c05ba1 100644
--- a/module/plugins/Hook.py
+++ b/module/plugins/Hook.py
@@ -36,7 +36,6 @@ class Hook():
self.config = core.config
self.interval = 60
- self.lastCall = 0
self.setup()
diff --git a/pyLoadCore.py b/pyLoadCore.py
index 5923a3d7f..eb6ffb468 100755
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -386,7 +386,6 @@ class Core(object):
self.threadManager.work()
self.scheduler.work()
- self.hookManager.periodical()
def init_server(self):
try: