diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2012-09-24 15:41:13 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2012-09-24 15:41:13 +0200 |
commit | fb145cf68c0178b9551eaae3213ec01be112bf76 (patch) | |
tree | 61d8dd381a831da4c34359b5e471e11d687f4746 /module/threads | |
parent | added some animations, code for show/hiding items (diff) | |
download | pyload-fb145cf68c0178b9551eaae3213ec01be112bf76.tar.xz |
fixed some things, so downloads works again
Diffstat (limited to 'module/threads')
-rw-r--r-- | module/threads/AddonThread.py | 2 | ||||
-rw-r--r-- | module/threads/BaseThread.py | 12 | ||||
-rw-r--r-- | module/threads/DownloadThread.py | 12 | ||||
-rw-r--r-- | module/threads/ThreadManager.py | 16 |
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() |