diff options
-rw-r--r-- | module/PluginThread.py | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/module/PluginThread.py b/module/PluginThread.py index 56c36c778..6dc6a0fe1 100644 --- a/module/PluginThread.py +++ b/module/PluginThread.py @@ -155,7 +155,7 @@ class DownloadThread(PluginThread): """Constructor""" PluginThread.__init__(self, manager) - self.queue = Queue() # job queue + self.queue = Queue() #: job queue self.active = False self.start() @@ -176,7 +176,8 @@ class DownloadThread(PluginThread): return True try: - if not pyfile.hasPlugin(): continue + if not pyfile.hasPlugin(): + continue #this pyfile was deleted while queueing pyfile.plugin.checkForSameFiles(starting=True) @@ -184,6 +185,7 @@ class DownloadThread(PluginThread): # start download self.m.core.hookManager.downloadPreparing(pyfile) + pyfile.error = "" pyfile.plugin.preprocessing(self) self.m.log.info(_("Download finished: %s") % pyfile.name) @@ -317,7 +319,7 @@ class DownloadThread(PluginThread): pyfile.checkIfProcessed() exc_clear() - + #pyfile.plugin.req.clean() self.active = False @@ -359,41 +361,41 @@ class DecrypterThread(PluginThread): retry = False try: - self.m.log.info(_("Decrypting starts: %s") % self.active.name) - self.active.plugin.preprocessing(self) + self.m.log.info(_("Decrypting starts: %s") % pyfile.name) + pyfile.error = "" + pyfile.plugin.preprocessing(self) except NotImplementedError: - self.m.log.error(_("Plugin %s is missing a function.") % self.active.pluginname) + self.m.log.error(_("Plugin %s is missing a function.") % pyfile.pluginname) return except Fail, e: msg = e.args[0] if msg == "offline": - self.active.setStatus("offline") - self.m.log.warning(_("Download is offline: %s") % self.active.name) + pyfile.setStatus("offline") + self.m.log.warning(_("Download is offline: %s") % pyfile.name) else: - self.active.setStatus("failed") - self.m.log.error(_("Decrypting failed: %(name)s | %(msg)s") % {"name": self.active.name, "msg": msg}) - self.active.error = msg + pyfile.setStatus("failed") + self.m.log.error(_("Decrypting failed: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": msg}) + pyfile.error = msg return except Abort: self.m.log.info(_("Download aborted: %s") % pyfile.name) pyfile.setStatus("aborted") - return except Retry: - self.m.log.info(_("Retrying %s") % self.active.name) + self.m.log.info(_("Retrying %s") % pyfile.name) retry = True return self.run() except Exception, e: - self.active.setStatus("failed") - self.m.log.error(_("Decrypting failed: %(name)s | %(msg)s") % {"name": self.active.name, "msg": str(e)}) - self.active.error = str(e) + pyfile.setStatus("failed") + self.m.log.error(_("Decrypting failed: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": str(e)}) + pyfile.error = str(e) if self.m.core.debug: print_exc() @@ -401,21 +403,14 @@ class DecrypterThread(PluginThread): return - finally: if not retry: - self.active.release() + pyfile.release() self.active = False self.m.core.files.save() self.m.localThreads.remove(self) exc_clear() - - #self.m.core.hookManager.downloadFinished(pyfile) - - - #self.m.localThreads.remove(self) - #self.active.finishIfDone() if not retry: pyfile.delete() @@ -461,7 +456,7 @@ class HookThread(PluginThread): #dirty method to filter out exceptions if "unexpected keyword argument 'thread'" not in e.args[0]: raise - + del self.kwargs["thread"] self.f(*self.args, **self.kwargs) finally: |