Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 2053a0d9eaaf755b990f80ce4df504a7 > files > 319

waf-1.5.9-1mdv2010.0.noarch.rpm

#! /usr/bin/env python
# encoding: utf-8
# Thomas Nagy, 2008 (ita)

"""
This example demonstrates how to modify the error handler to prevent the build from stopping
"""

VERSION= '0.0.1'
APPNAME= 'job_errors'
srcdir = '.'
blddir = 'build'

import Runner, Task, Options
import time

def error_handler(self, tsk):
	print "task failed! %r" % tsk
	self.error = 1
	#self.stop = 1

# try commenting the following line
Runner.Parallel.error_handler = error_handler


# the code below is generic
class base(Task.TaskBase):
	def run(self):
		print self.__class__.__name__ + " " + getattr(self, "id", "")
		time.sleep(self.__class__.duration)
		self.m_hasrun = 1

		if self.__class__.__name__ == "X":
			raise Exception, "test (don't panic): this exception is raised when the class name is 'X'"

class X(base):
	duration = 10

class Y(base):
	duration = 4

class Z(base):
	duration = 6

def build(bld):

	task_a = X()
	task_c = Z()
	task_b = Y()

	# force to run with 2 jobs
	Options.options.jobs = 2

def set_options(opt):
	pass

def configure(conf):
	pass