Runner

Runner.py: Task scheduling and execution

waflib.Runner.GAP

Wait for free tasks if there are at least GAP * njobs in queue

class waflib.Runner.TaskConsumer[source]

Bases: threading.Thread

Task consumers belong to a pool of workers

They wait for tasks in the queue and then use task.process(...)

ready

Obtain waflib.Task.TaskBase instances from this queue.

run()[source]

Loop over the tasks to execute

loop()[source]

Obtain tasks from waflib.Runner.TaskConsumer.ready and call waflib.Task.TaskBase.process(). If the object is a function, execute it.

waflib.Runner.pool

Pool of task consumer objects

waflib.Runner.get_pool()[source]

Obtain a task consumer from waflib.Runner.pool. Do not forget to put it back by using waflib.Runner.put_pool() and reset properly (original waiting queue).

Return type:waflib.Runner.TaskConsumer
waflib.Runner.put_pool(x)[source]

Return a task consumer to the thread pool waflib.Runner.pool

Parameters:x (waflib.Runner.TaskConsumer) – task consumer object
class waflib.Runner.Parallel(bld, j=2)[source]

Bases: object

Schedule 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

Number of consumers in the pool

bld

Instance of waflib.Build.BuildContext

outstanding

List of waflib.Task.TaskBase that may be ready to be executed

frozen

List of waflib.Task.TaskBase that cannot be executed immediately

out

List of waflib.Task.TaskBase returned by the task consumers

count

Amount of tasks that may be processed by waflib.Runner.TaskConsumer

processed

Amount of tasks processed

stop

Error flag to stop the build

error

Tasks that could not be executed

biter

Task iterator which must give groups of parallelizable tasks when calling next()

dirty

Flag to indicate that tasks have been executed, and that the build cache must be saved (call waflib.Build.BuildContext.store())

get_next_task()[source]

Obtain the next task to execute.

Return type:waflib.Task.TaskBase
postpone(tsk)[source]

A task cannot be executed at this point, put it in the list waflib.Runner.Parallel.frozen.

Parameters:tsk (waflib.Task.TaskBase) – task
refill_task_list()[source]

Put the next group of tasks to execute in waflib.Runner.Parallel.outstanding.

add_more_tasks(tsk)[source]

Tasks may be added dynamically during the build by binding them to the task waflib.Task.TaskBase.more_tasks

Parameters:tsk (waflib.Task.TaskBase) – task
get_out()[source]

Obtain one task returned from the task consumers, and update the task count. Add more tasks if necessary through waflib.Runner.Parallel.add_more_tasks.

Return type:waflib.Task.TaskBase
error_handler(tsk)[source]

Called when a task cannot be executed. The flag waflib.Runner.Parallel.stop is set, unless the build is executed with:

$ waf build -k
Parameters:tsk (waflib.Task.TaskBase) – task
add_task(tsk)[source]

Pass a task to a consumer.

Parameters:tsk (waflib.Task.TaskBase) – task
start()[source]

Give tasks to waflib.Runner.TaskConsumer instances until the build finishes or the stop flag is set. If only one job is used, then execute the tasks one by one, without consumers.

Previous topic

Options

Next topic

Scripting

This Page