Exemplo n.º 1
0
	def run(self):
		logger.info('EXECUTE THREAD HIEARCHY')
		slaves = self.create_slave_threads()

		# for each tier
		logger.meta('-'*80)
		for i, tier in enumerate(self.thread_hierarchy):
			i += 1
			
			try:
				# make all specified threadslaves execute their function
				logger.info('start executing tier no ' + str(i))
				for slave in slaves:
					if slave.tag in tier:
						(run_id, f) = tier.get(slave.tag)
						slave.execute((run_id, f))
				
				#wait for all threads to finish
				for slave in slaves:
					if slave.thread and slave.thread.isAlive():
						slave.thread.join()
					
					# test if any slaves have caused an exception, then rethrow it
					if slave.exception:
						raise slave.exception[1], None, slave.exception[2]
					if slave.thread and slave.thread.returncode != 0 and ctx.fail_fast:
						raise Fast_Fail_Exeception("remote execution exited with code %d!" % slave.thread.returncode)
					
			except Fast_Fail_Exeception, e:
				logger.error(e.message)
				logger.error('broke execution: an explanation ought to have been printed above me')
				break;
			
			finally:
Exemplo n.º 2
0
					if slave.tag in tier:
						(run_id, f) = tier.get(slave.tag)
						slave.execute((run_id, f))
				
				#wait for all threads to finish
				for slave in slaves:
					if slave.thread and slave.thread.isAlive():
						slave.thread.join()
					
					# test if any slaves have caused an exception, then rethrow it
					if slave.exception:
						raise slave.exception[1], None, slave.exception[2]
					if slave.thread and slave.thread.returncode != 0 and ctx.fail_fast:
						raise Fast_Fail_Exeception("remote execution exited with code %d!" % slave.thread.returncode)
					
			except Fast_Fail_Exeception, e:
				logger.error(e.message)
				logger.error('broke execution: an explanation ought to have been printed above me')
				break;
			
			finally:
				logger.meta('-'*80) #TODO: is everything shutdown properly?
				
		logger.info('Shutdown slaves')
		for slave in slaves:
			slave.close()
			
		logger.meta('-'*80)
		logger.info('THREAD HIEARCHY FINISHED')
		logger.meta('-'*80)
		logger.meta('')