summaryrefslogtreecommitdiffstats
path: root/module/ThreadManager.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/ThreadManager.py')
-rw-r--r--module/ThreadManager.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/module/ThreadManager.py b/module/ThreadManager.py
index 8937f4a29..bdc6ca6e2 100644
--- a/module/ThreadManager.py
+++ b/module/ThreadManager.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@@ -28,7 +27,7 @@ from random import choice
import pycurl
-import PluginThread
+from module.threads import PluginThread
from module.PyFile import PyFile
from module.network.RequestFactory import getURL
from module.utils import freeSpace, lock
@@ -146,7 +145,7 @@ class ThreadManager:
self.log.warning("Assign job error", e)
if self.core.debug:
print_exc()
-
+
sleep(0.5)
self.assignJob()
#it may be failed non critical so we try it again
@@ -156,7 +155,7 @@ class ThreadManager:
self.infoResults.clear()
self.log.debug("Cleared Result cache")
- #----------------------------------------------------------------------
+ #--------------------------------------------------------------------------
def tryReconnect(self):
"""checks if reconnect needed"""
@@ -227,7 +226,7 @@ class ThreadManager:
return ip
- #----------------------------------------------------------------------
+ #--------------------------------------------------------------------------
def checkThreadCount(self):
"""checks if there are need for increasing or reducing thread count"""
@@ -251,7 +250,7 @@ class ThreadManager:
self.log.debug("Cleaned up pycurl")
return True
- #----------------------------------------------------------------------
+ #--------------------------------------------------------------------------
def assignJob(self):
"""assing a job to a thread if possible"""
@@ -262,12 +261,12 @@ 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 = map(lambda x : (x[0], x[1], len([y for y in self.threads if y.active and y.active.pluginname == x[0]])) ,inuse)
+ 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 = 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 x[1] > 0 and x[2] >= x[1]]
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))
job = self.core.files.getJob(occ)
@@ -310,7 +309,7 @@ class ThreadManager:
thread = PluginThread.DecrypterThread(self, job)
def getLimit(self, thread):
- limit = thread.active.plugin.account.getAccountData(thread.active.plugin.user)["options"].get("limitDL",["0"])[0]
+ limit = thread.active.plugin.account.getAccountData(thread.active.plugin.user)["options"].get("limitDL", ["0"])[0]
return int(limit)
def cleanup(self):