def test_pool(self): pool = ExperimentPool(4) for i in range(0,15): pool.append( PoolExperiment(None, duration=random.randint(1,60)) ) for experiment in pool.run(): print "DONE: sleep " + str(experiment.parameters['duration']) self.assertEqual(1, False)
def test_pool(self): pool = ExperimentPool(4) for i in range(0,15): pool.append( PoolExperiment(None, duration=random.randint(1,6)) ) for experiment in pool.run(): print("DONE: sleep " + str(experiment.parameters['duration'])) self.assertTrue(True) #if we got here, no exceptions were raised and it's okay
#ports = range(BEGINPORT, BEGINPORT+poolsize) #if len(ports) >= 7: # raise Exception("Don't start too many frogs!") #for port in ports: # os.system('Frog --skip=tmp -S ' + str(port) + ' &') print "POPULATING POOL.." portindex = -1 for i, doc in enumerate( CorpusFiles(sonardir, 'tok', "", lambda f: not os.path.exists(f + '.pos')) ): #read the *.tok files, on condition there are no *.pos equivalents portindex += 1 if portindex == len(ports): portindex = 0 print '#' + str(i + 1) + ')\tQUEING\t' + doc + ' [' + str( ports[portindex]) + ']' pool.append(TagDoc((doc, ports[portindex], i + 1))) sys.stdout.flush() print "RUNNING POOL..." for experiment in pool.run(False): #does not halt on error sonardoc, tadpoleport, count = experiment.inputdata print '#' + str( count) + ')\tDONE\t' + sonardoc + '\t@ ' + datetime.datetime.now( ).strftime("%Y-%m-%d %H:%M:%S") print "POOL EMPTY.. ALL DONE!"