Drinkin gasoline and wine

post zenmachine musings

Agents and Event Listeners for Python

When modeling a distributed system one might stumble in the Actor model, implemented in one way or another - be it natively on Erlang or a complete library as Akka.

There is a lot of discussion over concurrency models, but regardless the Actor model serves well to break a task between different processes/servers.

Built usually over a messaging channel, these frameworks are usually adapted for a set of tasks. As it wouldn’t be different, some of them had a lot more than I needed, and the frameworks for Python were divided between trying to reimplement Akka or completely different concept.

I took some time out to build Mure to learn more about kombu, a multi-transport library for python. It’s a really simple actor library.

The decorator @worker() says that each time that a message to the queue named after the string arrives, the function might be executed having the message as parameter.

After fidling with pyee, I’ve implemented an EventEmitter on top of it. The syntax is the same as node.js, but it’s a distributed event emitter.