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)
1. Microprocesses - A Generator with Context
Axon is built on top of generators with some added context. Whilst the most common version of this a user actually uses is called a component, this is a specialisation of the general concept - a generator with context.
Exercise: Write a class called microprocess (make sure you subclass "object" !) with the following methods:
__init__(self)
main(self)
Answer:
Discussion:
Clearly we can create a handful of these now:
Calling their main method results in us being given a generator:
We can then run these generators in the usual way (though these are fairly boring microprocesses):
OK, so we have a mechanism for adding context to generators, and we've called that a microprocess. Let's make it simple to set lots of these running.