August'24: Kamaelia is in maintenance mode and will recieve periodic updates, about twice a year, primarily targeted around Python 3 and ecosystem compatibility. PRs are always welcome. Latest Release: 1.14.32 (2024/3/24)
For examples and more explanations, see the module level docs.
Scheduler - runs microthreads of control.
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.
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.
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([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 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(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.
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:
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).
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