3
# Thomas Nagy, 2005-2008 (ita)
5
import sys, random, time, traceback, os
6
import Build, Utils, Logs, Options
7
from Logs import debug, error
8
from Constants import *
10
class TaskConsumer(object):
20
tsk.generator.bld.printout(tsk.display())
21
if tsk.__class__.stat: ret = tsk.__class__.stat(tsk)
22
# actual call to task's run() function
23
else: ret = tsk.call_run()
25
tsk.err_msg = Utils.ex_stack()
26
tsk.hasrun = EXCEPTION
39
except Utils.WafError:
42
tsk.err_msg = Utils.ex_stack()
43
tsk.hasrun = EXCEPTION
46
if tsk.hasrun != SUCCESS:
55
self.refill_task_list()
57
# consider the next task
61
# tasks may add new ones after they are run
64
# no tasks to run, no tasks running, time to exit
68
# if the task is marked as "run", just skip it
70
self.manager.add_finished(tsk)
74
st = tsk.runnable_status()
77
if self.stop and not Options.options.keep:
79
self.manager.add_finished(tsk)
81
self.error_handler(tsk)
82
self.manager.add_finished(tsk)
83
tsk.hasrun = EXCEPTION
84
tsk.err_msg = Utils.ex_stack()
92
self.manager.add_finished(tsk)
94
# run me: put the task in ready queue
95
tsk.position = (self.processed, self.total)
102
# self.count represents the tasks that have been made available to the consumer threads
103
# collect all the tasks after an error else the message may be incomplete
104
while self.error and self.count:
108
assert (self.count == 0 or self.stop)
111
# enable nothreads if -j1 is used from the makefile
112
if os.environ.get('JOBS') == '1' or sys.platform == 'linux2-hppa':
114
Runner.Parallel.start = start