From 1e338a279aba747534fd1e7aedc8d7aec319f5f2 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Mon, 30 Dec 2013 19:52:29 +0100 Subject: show progress of decrypting and link checking, added indicator in link grabber --- pyload/threads/ThreadManager.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'pyload/threads/ThreadManager.py') diff --git a/pyload/threads/ThreadManager.py b/pyload/threads/ThreadManager.py index 3132e98e2..0e0b6320d 100644 --- a/pyload/threads/ThreadManager.py +++ b/pyload/threads/ThreadManager.py @@ -19,7 +19,7 @@ from os.path import exists, join import re from subprocess import Popen -from threading import Event, Lock +from threading import Event, RLock from time import sleep, time from traceback import print_exc from random import choice @@ -53,7 +53,7 @@ class ThreadManager: self.reconnecting.clear() self.downloaded = 0 #number of files downloaded since last cleanup - self.lock = Lock() + self.lock = RLock() # some operations require to fetch url info from hoster, so we caching them so it wont be done twice # contains a timestamp and will be purged after timeout @@ -71,13 +71,23 @@ class ThreadManager: for i in range(self.core.config.get("download", "max_downloads")): self.createThread() - def createThread(self): """create a download thread""" thread = DownloadThread(self) self.threads.append(thread) + @lock + def addThread(self, thread): + self.localThreads.append(thread) + + @lock + def removeThread(self, thread): + """ Remove a thread from the local list """ + if thread in self.localThreads: + self.localThreads.remove(thread) + + @lock def createInfoThread(self, data, pid): """ start a thread which fetches online status and other info's """ self.timestamp = time() + 5 * 60 -- cgit v1.2.3