Public Member Functions | |
def | __init__ |
def | activeThreads |
def | runTests |
Public Attributes | |
maxThreads | |
runDirs | |
threadList | |
workFlows |
Definition at line 10 of file MatrixRunner.py.
def MatrixRunner::MatrixRunner::__init__ | ( | self, | |
wfIn = None , |
|||
nThrMax = 4 |
|||
) |
Definition at line 12 of file MatrixRunner.py.
def MatrixRunner::MatrixRunner::activeThreads | ( | self | ) |
Definition at line 22 of file MatrixRunner.py.
def MatrixRunner::MatrixRunner::runTests | ( | self, | |
opt | |||
) |
Definition at line 31 of file MatrixRunner.py.
00032 : 00033 00034 testList=opt.testList 00035 dryRun=opt.dryRun 00036 cafVeto=opt.cafVeto 00037 00038 startDir = os.getcwd() 00039 00040 report='' 00041 noRun=(self.maxThreads==0) 00042 if noRun: 00043 print 'Not running the wf, only creating cfgs and logs' 00044 print 'resetting to default number of threads' 00045 self.maxThreads=4 00046 00047 print 'Running in %s thread(s)' % self.maxThreads 00048 00049 00050 for wf in self.workFlows: 00051 00052 if testList and float(wf.numId) not in [float(x) for x in testList]: continue 00053 00054 item = wf.nameId 00055 if os.path.islink(item) : continue # ignore symlinks 00056 00057 # make sure we don't run more than the allowed number of threads: 00058 while self.activeThreads() >= self.maxThreads: 00059 time.sleep(10) 00060 continue 00061 00062 print '\nPreparing to run %s %s' % (wf.numId, item) 00063 00064 current = WorkFlowRunner(wf,noRun,dryRun,cafVeto) 00065 self.threadList.append(current) 00066 current.start() 00067 if not dryRun: 00068 time.sleep(random.randint(1,5)) # try to avoid race cond by sleeping random amount of time [1,5] sec 00069 00070 # wait until all threads are finished 00071 while self.activeThreads() > 0: 00072 time.sleep(0.5) 00073 00074 00075 #wrap up ! 00076 totpassed=[] 00077 totfailed=[] 00078 def count(collect,result): 00079 #pad with zeros 00080 for i in range(len(collect),len(result)): 00081 collect.append(0) 00082 for i,c in enumerate(result): 00083 collect[i]+=c 00084 00085 for pingle in self.threadList: 00086 pingle.join() 00087 try: 00088 count(totpassed,pingle.npass) 00089 count(totfailed,pingle.nfail) 00090 report+=pingle.report 00091 self.runDirs[pingle.wf.numId]=pingle.wfDir 00092 except Exception, e: 00093 msg = "ERROR retrieving info from thread: " + str(e) 00094 report += msg 00095 00096 report+=' '.join(map(str,totpassed))+' tests passed, '+' '.join(map(str,totfailed))+' failed\n' 00097 print report 00098 00099 runall_report_name='runall-report-step123-.log' 00100 runall_report=open(runall_report_name,'w') 00101 runall_report.write(report) 00102 runall_report.close() 00103 os.chdir(startDir) 00104 00105 anyFail=sum(totfailed) 00106 00107 return anyFail 00108
Definition at line 12 of file MatrixRunner.py.
Definition at line 12 of file MatrixRunner.py.
Definition at line 12 of file MatrixRunner.py.
Definition at line 12 of file MatrixRunner.py.