Runner

Runner.py: Task scheduling and execution

waflib.Runner.GAP = 20

Wait for at least GAP * njobs before trying to enqueue more tasks to run

class waflib.Runner.Consumer(spawner, task)[source]

Bases: threading.Thread

Daemon 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

run()[source]

Processes a single task

class waflib.Runner.Spawner(master)[source]

Bases: threading.Thread

Daemon thread that consumes tasks from waflib.Runner.Parallel producer and spawns a consuming thread waflib.Runner.Consumer for each waflib.Task.TaskBase instance.

master = None

waflib.Runner.Parallel producer 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()

loop()[source]

Consumes task objects from the producer; ends when the producer has no more task to provide.

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 = None

Amount of parallel consumers to use

bld = None

Instance of waflib.Build.BuildContext

outstanding = None

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

frozen = None

List of waflib.Task.TaskBase that are not ready yet

ready = None

List of waflib.Task.TaskBase ready to be executed by consumers

out = None

List of waflib.Task.TaskBase returned 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.out after execution. Adds more Tasks if necessary through waflib.Runner.Parallel.add_more_tasks.

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

Enqueue a Task to waflib.Runner.Parallel.ready so that consumers can run them.

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

Mark a task as skipped/up-to-date

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 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_LATER
Return type:integer
start()[source]

Obtains Task instances from the BuildContext instance and adds the ones that need to be executed to waflib.Runner.Parallel.ready so that the waflib.Runner.Spawner consumer thread has them executed. Obtains the executed Tasks back from waflib.Runner.Parallel.out and marks the build as failed by setting the stop flag. If only one job is used, then executes the tasks one by one, without consumers.

Previous topic

Options

Next topic

Scripting

This Page