Hi Richard,
On Thursday 28 May 2009 16:50:19 Richard Miller wrote:
> Is there an example of kamaelia's inherent actor message passing
> 1) between differenct processes and 2) between processes on distributed
> computers.
Interprocess message passing in Kamaelia between processes is trivial for one
common case. Once common case is where you want to change this:
from Kamaelia.Chassis.Pipeline import Pipeline
Pipeline(
Source(),
TransformerOne(),
TransformerTwo(),
TransformerThree(),
Sink(),
)
To an example where this uses one process per sub component:
from Axon.experimental.Process import ProcessPipelineComponent
ProcessPipelineComponent(
Source(),
TransformerOne(),
TransformerTwo(),
TransformerThree(),
Sink(),
)
A concrete example of this is this:
from Axon.experimental.Process import ProcessPipelineComponent
from Kamaelia.UI.Pygame.Text import TextDisplayer, Textbox
ProcessPipelineComponent(
Textbox(position=(20, 340),
text_height=36,
screen_width=900,
screen_height=200,
background_color=(130,0,70),
text_color=(255,255,255)),
TextDisplayer(position=(20, 90),
text_height=36,
screen_width=900,
screen_height=200,
background_color=(130,0,70),
text_color=(255,255,255))
).run()
This opens two pygame windows, in two processes, and allows text to move
between the two. If you change the above example to this:
Pipeline(
Textbox(position=(20, 340),
text_height=36,
screen_width=900,
screen_height=200,
background_color=(130,0,70),
text_color=(255,255,255)),
TextDisplayer(position=(20, 90),
text_height=36,
screen_width=900,
screen_height=200,
background_color=(130,0,70),
text_color=(255,255,255))
).run()
You'll find they share the same process, and hence the same window.
For this to work this currently uses Paul Boddie's pprocess library:
* http://www.boddie.org.uk/python/pprocess.html
The reason this doesn't use the multiprocessing library is because it predates
the multiprocessing library going into the python core. At some point it will
be changed over to use the multiprocessing library.
The timing between the two was very close, which is why this has been left
marked experimental, but it is known stable.
This does also mean you can do things like this:
ProcessPipelineComponent(
Pipeline(
Source(),
TransformerOne(),
),
Pipeline(
TransformerTwo(),
TransformerThree(),
Sink(),
)
)
To split the pipeline across two processes, instead of 5. If you want to do
local initialisation in each process before running each pipeline, you can do
that like this:
ProcessPipelineComponent(
Seq(
InitialisationComponent()
Pipeline(
Source(),
TransformerOne(),
)
),
Seq(
InitialisationComponent()
Pipeline(
TransformerTwo(),
TransformerThree(),
Sink(),
)
)
)
The multi-machine case has not been cleanly addressed as yet, but there are a
number of options for building your own, since building servers in Kamaelia
is pretty trivial.
I'll knock up an sample job server and client system and post that to the
list shortly to show the sort of thing that would need doing.
Regards,
Michael.
--
http://yeoldeclue.com/blog
http://twitter.com/kamaelian
http://www.kamaelia.org/Home
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"kamaelia" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/kamaelia?hl=en
-~----------~----~----~----~------~----~------~--~---