Help me use my Dual Core CPU!

mystilleef mystilleef at gmail.com
Mon Sep 18 12:26:49 EDT 2006


Paul Rubin wrote:
> "mystilleef" <mystilleef at gmail.com> writes:
> > I use D-Bus (Python). I recommend it. I don't know how cross platform
> > it is. However, it supports message passing of most built-in (strings,
> > ints, lists, dictionaries etc) Python objects accross processes. You
> > can mimick clean Erlang-like concurrency with it. It is the future of
> > IPC on Desktop Unix. Given Python's crippled threading implementation,
> > it can play a role in making your Python applications scalable, with
> > regards to concurrency. I am recommending D-Bus because I have used it,
> > and I know it works. I didn't read this of a newsgroup or mailing list.
>
> It looks useful, but as far as I can tell, it's just another IPC
> thingie that works through sockets, sort of like pyro without the
> remote objects.  I don't see how it's related to Erlang-like
> concurrency (which means ultralightweight coroutines, not heavyweight
> Unix or Windows processes).  I think Python concurrency schemes get
> interesting when they at least share memory (like POSH).  Otherwise I
> think of them more as "distributed" than "concurrent".

What is revolutionary about Erlang's concurrency model isn't exactly
its light weight threads (Python already has a frame work that
implements something similar) but the fact that in Erlang each thread
behaves like a process and each thread communicates with each other via
message passing. In Erlang, threads do not share state information. So
all the limitations associated with concurrent programming in other
mainstream languages are absent in Erlang. Because threads behave like
processes and do not share state, Erlang allows you to create thousands
of threads easily without the drawbacks of thread locks. Each thread or
process manages its own state. Erlang then provides a protocol to allow
each thread to communicate with each other.

You can mimic this concept with a light weight event based IPC like
D-Bus. D-Bus supports message passing and signals. It also provides you
with an easy protocol that allows processes to talk to each other. You
are right when you say that D-Bus uses heavy processes while Erlang
uses light ones. But the robustness and scalability of Erlang's
concurrency model stems from the fact that Erlang's threads are not
really threads, but light weight processes that do not share state
information. In brief, Erlang's concurrency model is basically IPC
programming with light-weight processes. This is what I say you can
mimic with D-Bus albeit, unfortunately, with heavy-weight processes.




More information about the Python-list mailing list