April 2024 - This site, and Kamaelia are being updated. There is significant work needed, and PRs are welcome.


For examples and more explanations, see the module level docs.

class scheduler(Axon.Microprocess.microprocess)

Scheduler - runs microthreads of control.

Methods defined here

__init__(self, **argd)

Creates a scheduler object. If scheduler.run has not been set, sets it. Class initialisation ensures that this object/class attribute is initialised - client modules always have access to a standalone scheduler. Internal attributes:

  • time = time when this object was last active.
  • threads = set of threads to be run, including their state - whether active or sleeping(paused)

Whilst there can be more than one scheduler active in the general case you will NOT want to create a custom scheduler.

_addThread(self, mprocess)

A Microprocess adds itself to the runqueue using this method, using the mannerism scheduler.run._addThread(). Generally component writers should not use this method to activate a component - use the component's own activate() method instead.

handleMicroprocessShutdownKnockon(self, knockon)

isThreadPaused(self, mprocess)

Returns True if the specified microprocess is sleeping, or the scheduler does not know about it.


Returns a list of all microprocesses (both active and sleeping)

main(self[, slowmo][, canblock])

main([slowmo][,canblock]) - Scheduler main loop generator

Each cycle through this generator does two things: * one pass through all active microprocesses, giving executing them. * processing of wake/sleep requests

You can optionally slow down execution to aid debugging. You can also allow the scheduler to block if there are no active, awake microprocesses.

Keyword arguments:

  • slowmo -- slow down execution by waiting this number of seconds each cycle (default=0)
  • canblock -- if True, then will block (waiting for wake requests) if all microprocesses are sleeping (default=False)

slowmo specifies a delay (in seconds) before the main loop is run. slowmo defaults to 0.

If canblock is True, this generator will briefly) block if there are no active microprocesses, otherwise it will return immediately (default).

This generator terminates when there are no microprocesses left (either sleeping or awake) because they've all terminated. (or because there were none to begin with!)

pauseThread(self, mprocess)

pauseThread(mprocess) - request to put a mprocess to sleep.

If active, or already sleeping, the specified microprocess will be put to leep on the next cycle through the scheduler.

runThreads(self[, slowmo])

Runs the scheduler until there are no activated microprocesses left (they've all terminated).

Think of this as bootstrapping the scheduler - after all it is a microprocess like any other, so needs something to run it!

Keyword arguments:

  • slowmo -- Optional. Number of seconds to wait between each cycle of executing microprocesses. (default=0 - no wait)



wakeThread(self, mprocess[, canActivate])

Request to wake a sleeping mprocess, or activate a new one.

If sleeping or already active, the specified microprocess will be ensured to be active on the next cycle through the scheduler.

If the microprocess is not running yet then it will be woken if (and only if) canActivate is set to True (the default is False).

Methods inherited from Axon.Microprocess.microprocess :


Got a problem with the documentation? Something unclear that could be clearer? Want to help improve it? Constructive criticism is very welcome - especially if you can suggest a better rewording!

Please leave you feedback here in reply to the documentation thread in the Kamaelia blog.

-- Automatic documentation generator, 09 Dec 2009 at 04:00:25 UTC/GMT