summaryrefslogtreecommitdiffstats
path: root/module/threads
diff options
context:
space:
mode:
Diffstat (limited to 'module/threads')
-rw-r--r--module/threads/AddonThread.py2
-rw-r--r--module/threads/BaseThread.py12
-rw-r--r--module/threads/DownloadThread.py12
-rw-r--r--module/threads/ThreadManager.py16
4 files changed, 28 insertions, 14 deletions
diff --git a/module/threads/AddonThread.py b/module/threads/AddonThread.py
index b6a552e0e..afb56f66b 100644
--- a/module/threads/AddonThread.py
+++ b/module/threads/AddonThread.py
@@ -52,7 +52,7 @@ class AddonThread(BaseThread):
except Exception, e:
if hasattr(self.f, "im_self"):
addon = self.f.im_self
- addon.logError(_("An Error occured"), e)
+ addon.logError(_("An Error occurred"), e)
if self.m.core.debug:
print_exc()
self.writeDebugReport(addon.__name__, plugin=addon)
diff --git a/module/threads/BaseThread.py b/module/threads/BaseThread.py
index 7a0ee5ee4..3e27eec96 100644
--- a/module/threads/BaseThread.py
+++ b/module/threads/BaseThread.py
@@ -24,6 +24,13 @@ class BaseThread(Thread):
self.core = manager.core
self.log = manager.core.log
+ def getProgress(self):
+ """ retrieves progress information about the current running task
+
+ :return: :class:`ProgressInfo`
+ """
+
+ # Debug Stuff
def writeDebugReport(self, name, pyfile=None, plugin=None):
""" writes a debug report to disk """
@@ -129,8 +136,3 @@ class BaseThread(Thread):
def getSystemDump(self):
return ""
-
- def clean(self, pyfile):
- """ set thread inactive and release pyfile """
- self.active = False
- pyfile.release()
diff --git a/module/threads/DownloadThread.py b/module/threads/DownloadThread.py
index 0269b0660..cf59c5639 100644
--- a/module/threads/DownloadThread.py
+++ b/module/threads/DownloadThread.py
@@ -38,7 +38,7 @@ class DownloadThread(BaseThread):
BaseThread.__init__(self, manager)
self.queue = Queue() # job queue
- self.active = False
+ self.active = None
self.start()
@@ -52,7 +52,7 @@ class DownloadThread(BaseThread):
pyfile = self.active
if self.active == "quit":
- self.active = False
+ self.active = None
self.m.threads.remove(self)
return True
@@ -212,11 +212,19 @@ class DownloadThread(BaseThread):
pyfile.finishIfDone()
self.core.files.save()
+ def getProgress(self):
+ if self.active:
+ return self.active.getProgressInfo()
+
def put(self, job):
"""assign a job to the thread"""
self.queue.put(job)
+ def clean(self, pyfile):
+ """ set thread inactive and release pyfile """
+ self.active = False
+ pyfile.release()
def stop(self):
"""stops the thread"""
diff --git a/module/threads/ThreadManager.py b/module/threads/ThreadManager.py
index e3407aac3..a0ece3463 100644
--- a/module/threads/ThreadManager.py
+++ b/module/threads/ThreadManager.py
@@ -26,7 +26,7 @@ from random import choice
import pycurl
-from module.datatypes import PyFile
+from module.datatypes.PyFile import PyFile
from module.network.RequestFactory import getURL
from module.utils import lock, uniqify
from module.utils.fs import free_space
@@ -118,8 +118,11 @@ class ThreadManager:
def setInfoResults(self, rid, result):
self.infoResults[rid].update(result)
+ def getActiveDownloads(self):
+ return [x.active for x in self.threads if x.active and isinstance(x.active, PyFile)]
+
def getActiveFiles(self):
- active = [x.active for x in self.threads if x.active and isinstance(x.active, PyFile)]
+ active = self.getActiveDownloads()
for t in self.localThreads:
active.extend(t.getActiveFiles())
@@ -130,6 +133,8 @@ class ThreadManager:
"""get a id list of all pyfiles processed"""
return [x.id for x in self.getActiveFiles()]
+ def allProgressInfo(self):
+ pass #TODO
def work(self):
"""run all task which have to be done (this is for repetetive call by core)"""
@@ -138,16 +143,15 @@ class ThreadManager:
except Exception, e:
self.log.error(_("Reconnect Failed: %s") % str(e) )
self.reconnecting.clear()
- if self.core.debug:
- print_exc()
+ self.core.print_exc()
+
self.checkThreadCount()
try:
self.assignJob()
except Exception, e:
self.log.warning("Assign job error", e)
- if self.core.debug:
- print_exc()
+ self.core.print_exc()
sleep(0.5)
self.assignJob()