Advanced concurrancy

Matt Hammond groups at matthammond.org
Thu Aug 4 05:15:51 EDT 2005


Hi Stefan,

> It seems as though all components basically have to do busy waiting now.

You are right - components are, for the most part, busy-waiting. Which
is not a good thing!

> So do you plan on including a kind of scheduler-aware blocking
> communication (like the `channels` of the `tasklets` in stackless)?
>
> (as you have a postman already - not a bad idea i think if you compare
> with multi-agent-systems theory (see jade) - it could be responsible for
> alerting the scheduler of box.has_data)

There is basic support for components to block, by calling the
self.pause() method. From the next yield, this blocks further execution
until
data arrives on any inbox.

The un-pausing action is actually performed by code within the
component
itself, though this is in effect, as you suggested it might be,
instigated by
the postman microprocess.

A simple example would be an improved 'consoleEcho' component:

class consoleEchoer(Axon.Component.component):
    ....
    def main(self):
        while 1:
            yield 1
            while self.dataReady("inbox"):
                print self.recv("inbox")
            self.pause()

That said, if you look at the code, you'll see that probably the
majority of components do not make good use of this yet!

There are quite probably better mechanisms around - hence the
distinction, in the code, between microprocesses and components.
We'd be very interested if yourself or other people want to play with
alternative communication & blocking mechanisms.

I'd hope that even if the components and postboxes model doesn't
work out in the long run, the underlying generator based
microprocesses code could still be of some value to others!


regards


Matt




More information about the Python-list mailing list