diff options
author | 2014-01-19 22:07:30 +0100 | |
---|---|---|
committer | 2014-01-19 22:07:30 +0100 | |
commit | 64570fa1697458705a94ae57af542af920cf0054 (patch) | |
tree | 41b7ed3a614bcf2dafced869f1b9c55858453783 /pyload/datatypes/PyFile.py | |
parent | better log message (diff) | |
download | pyload-64570fa1697458705a94ae57af542af920cf0054.tar.xz |
fixes for download scheduler
Diffstat (limited to 'pyload/datatypes/PyFile.py')
-rw-r--r-- | pyload/datatypes/PyFile.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/pyload/datatypes/PyFile.py b/pyload/datatypes/PyFile.py index 720b97cda..8f33b09fd 100644 --- a/pyload/datatypes/PyFile.py +++ b/pyload/datatypes/PyFile.py @@ -151,7 +151,7 @@ class PyFile(object): @read_lock def hasPlugin(self): """Thread safe way to determine this file has initialized plugin attribute""" - return hasattr(self, "plugin") and self.plugin + return self.plugin is not None def package(self): """ return package instance""" @@ -182,9 +182,9 @@ class PyFile(object): @lock def release(self): """sync and remove from cache""" - if hasattr(self, "plugin") and self.plugin: + if self.plugin is not None: self.plugin.clean() - del self.plugin + self.plugin = None self.m.releaseFile(self.fid) @@ -202,30 +202,28 @@ class PyFile(object): def move(self, pid): pass - @read_lock def abortDownload(self): """abort pyfile if possible""" # TODO: abort timeout, currently dead locks while self.fid in self.m.core.dlm.processingIds(): + + self.lock.acquire(shared=True) self.abort = True if self.plugin and self.plugin.req: self.plugin.req.abort() if self.plugin.dl: self.plugin.dl.abort() + self.lock.release() - sleep(0.1) + sleep(0.5) self.abort = False - if self.plugin: - self.plugin.req.abort() - if self.plugin.dl: - self.plugin.dl.abort() - self.release() def finishIfDone(self): """set status to finish and release file if every thread is finished with it""" + # TODO: this is wrong now, it should check if addons are using it if self.id in self.m.core.dlm.processingIds(): return False |