Runner¶
Runner.py: Task scheduling and execution
-
waflib.Runner.GAP= 20¶ Wait for at least
GAP * njobsbefore trying to enqueue more tasks to run
-
class
waflib.Runner.Consumer(spawner, task)[source]¶ Bases:
threading.ThreadDaemon thread object that executes a task. It shares a semaphore with the coordinator
waflib.Runner.Spawner. There is one instance per task to consume.-
task= None¶ Task to execute
-
spawner= None¶ Coordinator object
-
-
class
waflib.Runner.Spawner(master)[source]¶ Bases:
threading.ThreadDaemon thread that consumes tasks from
waflib.Runner.Parallelproducer and spawns a consuming threadwaflib.Runner.Consumerfor eachwaflib.Task.TaskBaseinstance.-
master= None¶ waflib.Runner.Parallelproducer instance
-
sem= None¶ Bounded semaphore that prevents spawning more than n concurrent consumers
-
run()[source]¶ Spawns new consumers to execute tasks by delegating to
waflib.Runner.Spawner.loop()
-
-
class
waflib.Runner.Parallel(bld, j=2)[source]¶ Bases:
objectSchedule the tasks obtained from the build context for execution.
-
__init__(bld, j=2)[source]¶ The initialization requires a build context reference for computing the total number of jobs.
-
numjobs= None¶ Amount of parallel consumers to use
-
bld= None¶ Instance of
waflib.Build.BuildContext
-
outstanding= None¶ List of
waflib.Task.TaskBasethat may be ready to be executed
-
frozen= None¶ List of
waflib.Task.TaskBasethat are not ready yet
-
ready= None¶ List of
waflib.Task.TaskBaseready to be executed by consumers
-
out= None¶ List of
waflib.Task.TaskBasereturned by the task consumers
-
count= None¶ Amount of tasks that may be processed by
waflib.Runner.TaskConsumer
-
processed= None¶ Amount of tasks processed
-
stop= None¶ Error flag to stop the build
-
error= None¶ Tasks that could not be executed
-
biter= None¶ Task iterator which must give groups of parallelizable tasks when calling
next()
-
dirty= None¶ Flag that indicates that the build cache must be saved when a task was executed (calls
waflib.Build.BuildContext.store())
-
spawner= None¶ Coordinating daemon thread that spawns thread consumers
-
get_next_task()[source]¶ Obtains the next Task instance to run
Return type: waflib.Task.TaskBase
-
postpone(tsk)[source]¶ Adds the task to the list
waflib.Runner.Parallel.frozen. The order is scrambled so as to consume as many tasks in parallel as possible.Parameters: tsk ( waflib.Task.TaskBase) – task instance
-
refill_task_list()[source]¶ Adds the next group of tasks to execute in
waflib.Runner.Parallel.outstanding.
-
add_more_tasks(tsk)[source]¶ If a task provides
waflib.Task.TaskBase.more_tasks, then the tasks contained in that list are added to the current build and will be processed before the next build group.Parameters: tsk ( waflib.Task.TaskBase) – task instance
-
get_out()[source]¶ Waits for a Task that task consumers add to
waflib.Runner.Parallel.outafter execution. Adds more Tasks if necessary throughwaflib.Runner.Parallel.add_more_tasks.Return type: waflib.Task.TaskBase
-
add_task(tsk)[source]¶ Enqueue a Task to
waflib.Runner.Parallel.readyso that consumers can run them.Parameters: tsk ( waflib.Task.TaskBase) – task instance
-
error_handler(tsk)[source]¶ Called when a task cannot be executed. The flag
waflib.Runner.Parallel.stopis set, unless the build is executed with:$ waf build -k
Parameters: tsk ( waflib.Task.TaskBase) – task instance
-
task_status(tsk)[source]¶ Obtains the task status to decide whether to run it immediately or not.
Returns: the exit status, for example waflib.Task.ASK_LATERReturn type: integer
-
start()[source]¶ Obtains Task instances from the BuildContext instance and adds the ones that need to be executed to
waflib.Runner.Parallel.readyso that thewaflib.Runner.Spawnerconsumer thread has them executed. Obtains the executed Tasks back fromwaflib.Runner.Parallel.outand marks the build as failed by setting thestopflag. If only one job is used, then executes the tasks one by one, without consumers.
-