Schedules threads to be run. No prioritization. Nothing fancy.
Methods:
add Add a thread to be run.
num_left Return the number of threads left.
num_running Return the number of threads currently running.
run Main loop. Returns whether there's still threads left.
Methods
|
|
__init__
add
num_left
num_running
run
|
|
__init__
|
__init__ (
self,
max_threads,
start_fn=None,
finish_fn=None,
)
Scheduler(max_threads[, start_fn][, finish_fn]) -> object
max_threads is the maximum number of threads to run at a time.
start_fn and finish_fn are optional callbacks that take a
thread as an argument. They are called before and after each
thread.
Exceptions
|
|
ValueError, "You must specify a positive number of threads!"
|
|
|
add
|
add ( self, thread )
add(thread)
|
|
num_left
|
num_left ( self )
num_left() -> number of threads left to run
|
|
num_running
|
num_running ( self )
num_running() -> number of threads currently running
|
|
run
|
run ( self )
run() -> boolean Execute the main loop. Return a boolean indicating whether
threads are still running.
|
|