summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-01-20 00:01:15 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-01-20 00:01:15 +0100
commit21791b33f033c7a182e64ca6f878bf0ec1d8f88d (patch)
tree66e8063781b61a720dd52520cc6935987ee44ce2 /module
parentcorrected log method (diff)
downloadpyload-21791b33f033c7a182e64ca6f878bf0ec1d8f88d.tar.xz
parallel dl limit for hoster
Diffstat (limited to 'module')
-rw-r--r--module/plugins/Hoster.py20
-rw-r--r--module/threads/ThreadManager.py12
2 files changed, 22 insertions, 10 deletions
diff --git a/module/plugins/Hoster.py b/module/plugins/Hoster.py
index 4a5d15759..c30fed412 100644
--- a/module/plugins/Hoster.py
+++ b/module/plugins/Hoster.py
@@ -65,7 +65,6 @@ class Hoster(Base):
self.wantReconnect = False
#: enables simultaneous processing of multiple downloads
- self.multiDL = True
self.limitDL = 0
#: chunk limit
self.chunkLimit = 1
@@ -113,11 +112,30 @@ class Hoster(Base):
self.init()
+ def getMultiDL(self):
+ self.logDebug("Deprectated attribute multiDL, use limitDL instead")
+ return self.limitDL <= 0
+
+ def setMultiDL(self, val):
+ self.logDebug("Deprectated attribute multiDL, use limitDL instead")
+ self.limitDL = 0 if val else 1
+
+ multiDL = property(getMultiDL, setMultiDL)
+
def getChunkCount(self):
if self.chunkLimit <= 0:
return self.config["download"]["chunks"]
return min(self.config["download"]["chunks"], self.chunkLimit)
+ def getDownloadLimit(self):
+ if self.account:
+ limit = self.account.options.get("limitDL", 0)
+ if limit == "": limit = 0
+ return int(limit)
+ else:
+ return self.limitDL
+
+
def __call__(self):
return self.__name__
diff --git a/module/threads/ThreadManager.py b/module/threads/ThreadManager.py
index 612da2536..6a5096b8c 100644
--- a/module/threads/ThreadManager.py
+++ b/module/threads/ThreadManager.py
@@ -30,7 +30,7 @@ import pycurl
from module.PyFile import PyFile
from module.network.RequestFactory import getURL
-from module.utils import lock
+from module.utils import lock, uniqify
from module.utils.fs import free_space
from DecrypterThread import DecrypterThread
@@ -264,14 +264,14 @@ class ThreadManager:
free = [x for x in self.threads if not x.active]
- inuse = set([(x.active.pluginname,self.getLimit(x)) for x in self.threads if x.active and x.active.hasPlugin() and x.active.plugin.account])
+ inuse = uniqify([(x.active.pluginname, x.active.plugin.getDownloadLimit()) for x in self.threads if x.active and x.active.hasPlugin()])
inuse = map(lambda x : (x[0], x[1], len([y for y in self.threads if y.active and y.active.pluginname == x[0]])) ,inuse)
onlimit = [x[0] for x in inuse if 0 < x[1] <= x[2]]
occ = [x.active.pluginname for x in self.threads if x.active and x.active.hasPlugin() and not x.active.plugin.multiDL] + onlimit
occ.sort()
- occ = tuple(set(occ))
+ occ = tuple(uniqify(occ))
job = self.core.files.getJob(occ)
if job:
try:
@@ -299,12 +299,6 @@ class ThreadManager:
self.core.files.jobCache[occ] = []
self.core.files.jobCache[occ].append(job.id)
- def getLimit(self, thread):
- limit = thread.active.plugin.account.options.get("limitDL","0")
- if limit == "": limit = "0"
- return int(limit)
-
-
def cleanup(self):
"""do global cleanup, should be called when finished with pycurl"""
pycurl.global_cleanup()