def findRunnableThreads(threads, threadsdone, threadsrunning): returnme = [] cpumax = fsutil.getCPUCount() current = 0 for i in threads: if not i["tn"] in threadsdone and current < cpumax: deps = 0 depsl = len(i["deps"]) for x in i["deps"]: if x["tn"] in threadsdone: deps = deps + 1 if deps >= depsl: returnme.append(i) current = current + 1 if current >= cpumax: break return returnme
# -*- coding: utf-8 -*- ''' Thread Managing Class @author: Joel Leclerc (MiJyn) <*****@*****.**> ''' from relinux import config, fsutil, logger, utilities from PyQt4 import QtCore import time import threading import copy tn = logger.genTN("TheadManager") cpumax = fsutil.getCPUCount() * 2 # Custom thread class class Thread(QtCore.QThread): def __init__(self, **kw): QtCore.QThread.__init__(self) for i in kw: self.__dict__[i] = kw[i] def is_alive(self): return self.isRunning() def isAlive(self): return self.is_alive() def run(self):