diff options
| author | 2014-01-18 19:44:49 +0100 | |
|---|---|---|
| committer | 2014-01-18 19:44:49 +0100 | |
| commit | 64bd06600d98bf1cb52b48fbac626c15407183d3 (patch) | |
| tree | 649ecf95b6ff85400fc7445f3f6e2e9957db9616 /pyload | |
| parent | rewritten download scheduling, improved account manager, db version increased... (diff) | |
| download | pyload-64bd06600d98bf1cb52b48fbac626c15407183d3.tar.xz | |
some fixes for new dl manager
Diffstat (limited to 'pyload')
| -rw-r--r-- | pyload/DownloadManager.py | 23 | ||||
| -rw-r--r-- | pyload/FileManager.py | 2 | ||||
| -rw-r--r-- | pyload/datatypes/PyFile.py | 2 | ||||
| -rw-r--r-- | pyload/threads/DownloadThread.py | 30 | 
4 files changed, 35 insertions, 22 deletions
diff --git a/pyload/DownloadManager.py b/pyload/DownloadManager.py index 04c9f66df..55e499bc7 100644 --- a/pyload/DownloadManager.py +++ b/pyload/DownloadManager.py @@ -97,7 +97,7 @@ class DownloadManager:      @lock      def startDecrypterThread(self, info):          """ Start decrypting of entered data, all links in one package are accumulated to one thread.""" -        self.decrypter.append(DecrypterThread(self, [(info.plugin, info.url)], info.pid)) +        self.decrypter.append(DecrypterThread(self, [(info.download.plugin, info.download.url)], info.pid))      @read_lock      def activeDownloads(self, uid=None): @@ -106,12 +106,17 @@ class DownloadManager:                  if uid is None or x.active.owner == uid]      @read_lock +    def waitingDownloads(self): +        """ all waiting downloads """ +        return [x.active for x in self.working if x.active.hasStatus("waiting")] + +    @read_lock      def getProgressList(self, uid):          """ Progress of all running downloads """          # decrypter progress could be none          return filter(lambda x: x is not None,                        [p.getProgress() for p in self.working + self.decrypter -                if uid is None or p.owner == uid]) +                       if uid is None or p.owner == uid])      def processingIds(self):          """get a id list of all pyfiles processed""" @@ -149,10 +154,20 @@ class DownloadManager:          self.assignJobs() +        # TODO: clean free threads +      def assignJobs(self):          """ Load jobs from db and try to assign them """          limit = self.core.config['download']['max_downloads'] - len(self.activeDownloads()) + +        # check for waiting dl rule +        if limit <= 0: +            # increase limit if there are waiting downloads +            limit += min(self.waitingDownloads(), self.core.config['download']['wait_downloads'] + +                                                  self.core.config['download']['max_downloads'] - len( +                self.activeDownloads())) +          slots = self.getRemainingPluginSlots()          occ = tuple([plugin for plugin, v in slots.iteritems() if v == 0])          jobs = self.core.files.getJobs(occ) @@ -181,8 +196,8 @@ class DownloadManager:      def chooseJobs(self, jobs, k):          """ make a fair choice of which k jobs to start """          # TODO: prefer admins, make a fairer choice? -        if k >= len(jobs): -            return jobs +        if k <= 0: return [] +        if k >= len(jobs): return jobs          return sample(jobs, k) diff --git a/pyload/FileManager.py b/pyload/FileManager.py index 9702307a0..17912e36d 100644 --- a/pyload/FileManager.py +++ b/pyload/FileManager.py @@ -313,7 +313,7 @@ class FileManager:          pid = f.packageid          order = f.fileorder -        if fid in self.core.threadManager.processingIds(): +        if fid in self.core.dlm.processingIds():              f.abortDownload()          self.db.deleteFile(fid, f.fileorder, f.packageid) diff --git a/pyload/datatypes/PyFile.py b/pyload/datatypes/PyFile.py index b83a057aa..720b97cda 100644 --- a/pyload/datatypes/PyFile.py +++ b/pyload/datatypes/PyFile.py @@ -206,7 +206,7 @@ class PyFile(object):      def abortDownload(self):          """abort pyfile if possible"""          # TODO: abort timeout, currently dead locks -        while self.id in self.m.core.dlm.processingIds(): +        while self.fid in self.m.core.dlm.processingIds():              self.abort = True              if self.plugin and self.plugin.req:                  self.plugin.req.abort() diff --git a/pyload/threads/DownloadThread.py b/pyload/threads/DownloadThread.py index b8f7e4965..3ee9466b8 100644 --- a/pyload/threads/DownloadThread.py +++ b/pyload/threads/DownloadThread.py @@ -1,22 +1,20 @@  #!/usr/bin/env python  # -*- coding: utf-8 -*- -""" -    This program is free software; you can redistribute it and/or modify -    it under the terms of the GNU General Public License as published by -    the Free Software Foundation; either version 3 of the License, -    or (at your option) any later version. - -    This program is distributed in the hope that it will be useful, -    but WITHOUT ANY WARRANTY; without even the implied warranty of -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -    See the GNU General Public License for more details. - -    You should have received a copy of the GNU General Public License -    along with this program; if not, see <http://www.gnu.org/licenses/>. - -    @author: RaNaN -""" +############################################################################### +#   Copyright(c) 2008-2014 pyLoad Team +#   http://www.pyload.org +# +#   This file is part of pyLoad. +#   pyLoad is free software: you can redistribute it and/or modify +#   it under the terms of the GNU Affero General Public License as +#   published by the Free Software Foundation, either version 3 of the +#   License, or (at your option) any later version. +# +#   Subjected to the terms and conditions in LICENSE +# +#   @author: RaNaN +###############################################################################  from threading import Event  from Queue import Queue  | 
