From 34a1ada97b5a7e5e353491ba0663bb6e27d3c57a Mon Sep 17 00:00:00 2001 From: RaNaN Date: Wed, 17 Jun 2009 10:39:54 +0200 Subject: file_list saves links, links.txt only for link dumping --- module/thread_list.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'module/thread_list.py') diff --git a/module/thread_list.py b/module/thread_list.py index 62131b20e..54a17e318 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -17,13 +17,11 @@ # along with this program; if not, see . # ### -#python from __future__ import with_statement import re import subprocess import time import urllib2 - from threading import RLock from download_thread import Download_Thread @@ -31,11 +29,9 @@ from download_thread import Download_Thread class Thread_List(object): def __init__(self, parent): self.parent = parent - self.list = parent.file_list + self.list = parent.file_list #file list self.threads = [] self.max_threads = int(self.parent.config['max_downloads']) - # self.py_load_files = [] # files in queque - # self.f_relation = [0, 0] self.lock = RLock() self.py_downloading = [] # files downloading self.occ_plugins = [] #occupied plugins @@ -55,7 +51,7 @@ class Thread_List(object): self.threads.remove(thread) def select_thread(self): - """ select a thread + """ create all threads """ while len(self.threads) < self.max_threads: self.create_thread() @@ -89,6 +85,7 @@ class Thread_List(object): def job_finished(self, pyfile): + """manage completing download""" self.lock.acquire() if not pyfile.plugin.multi_dl: @@ -99,6 +96,8 @@ class Thread_List(object): if pyfile.status.type == "finished": self.parent.logger.info('Download finished: ' + pyfile.url + ' @' + str(pyfile.status.get_speed()) + 'kb/s') + self.list.remove(pyfile) + if pyfile.plugin.props['type'] == "container": self.list.extend(pyfile.plugin.links) @@ -112,6 +111,10 @@ class Thread_List(object): with open(self.parent.config['failed_file'], 'a') as f: f.write(pyfile.url + "\n") + self.list.remove(pyfile) + + self.list.save() + self.lock.release() return True -- cgit v1.2.3