13

Is there anything for Python that has concurrency like Erlang does, particulary transparent actors over networks? I've looked at things like greenlet and stackless, but they don't seem to have network transparency for actors.

I still can't quite jump the hurdle of Erlang/OTP so I'm interested if there's something closer to home.

Makoto
  • 104,088
  • 27
  • 192
  • 230
  • Can you elaborate a little bit on what you're trying to achieve? – jathanism Apr 01 '11 at 22:29
  • 1
    @jathanism horizontal scalability with actors across multiple nodes, in a nutshell. –  Apr 01 '11 at 22:30
  • Python doesn't even have interpreter concurrency on multiple cores, what makes you think it's going to have it on multiple networked machines? – Amber Apr 01 '11 at 22:33
  • @Amber ``multiprocessing`` and pipes to the rescue? –  Apr 01 '11 at 22:34
  • 5
    I can only recomment to "jump the hurdle". Learing Erlang is fun, learning new programming languages is allways fun anyway and very usefull to get new insights -- make the habbit of learning 1 new language per year -- I've used Erlang the first time in a real-world project with a deadline and the increased productivity brought to me by Erlang was worth the learning time -- didn't miss my deadline :-) – Peer Stritzinger Apr 02 '11 at 11:30

7 Answers7

7

Instead of trying to make Python more like Erlang, how about making Erlang more like Python?

Efene and Elixir are language compilers that produce BEAM files which can take advantage of all the features of the Erlang BEAM emulator including network-transparent messaging.

Efene has an "ifene" variant that defines blocks with whitespace, like Python. Otherwise, it is most similar to JavaScript.

Elixir syntax is closest to Ruby.

Both languages are closer to Python than Erlang.

Kijewski
  • 25,517
  • 12
  • 101
  • 143
Warren Young
  • 40,875
  • 8
  • 85
  • 101
  • I've looked at those, and they don't look quite mature enough for production use... –  Apr 02 '11 at 02:09
3

Not really. Erlang was designed from the ground up to support actors, Python wasn't. The closest I can think of that fits the bill is the Candygram library, but even that's not quite right.

Keith Gaughan
  • 21,367
  • 3
  • 32
  • 30
  • 3
    I don't like how Candygram uses heavy OS threads, to be honest. –  Apr 01 '11 at 22:36
  • It could be rewritten to use green threads and multiprocessing. The use of OS threads is due to there being no feasible alternative at the time it was first written. The main point is that it at least implements the concurrency primitives. – Keith Gaughan Apr 01 '11 at 22:38
  • 1
    Its important to note that Erlang was *not* designed to support "actors". It incidentally implements a model *very similar to actors*. – zxq9 May 18 '15 at 04:49
2

Try Axon / Kamaelia

It's compatible with PyPy, so you get actor/flow-based programming and significantly accelerated execution speeds with PyPy's JIT.

eris0xff
  • 21
  • 1
1

caine, a package I created and named after this guy, implements caine.SupportingActor, a user-friendly concurrent actor model for python.

By default, caine.SupportingActor class has the following attributes/functions:

  • inbox : a managed queue. Messages are passed to the actor like so, foo.inbox.put('bar').
  • timeout : the allowed number of seconds between message receptions before timing out.
  • receive : a function to execute using messages from the inbox, requires implementation.
  • handle : a function to execute when an exception is raised.
  • callback : a function to execute when processing is complete.
  • cut : ends processing when called.

Additionally the caine.SupportingCast class inherits all the functions of caine.SupportingActor while allowing a specified number of actors to each process messages from the same inbox without duplication.

Will Weiss
  • 11
  • 1
0

See Pykka. I'm not sure how it handles errors.

fread2281
  • 1,136
  • 1
  • 11
  • 31
0

It's not really concurrency, but Celery may give you something of what your looking for, in terms of distributing task load over a network.

monkut
  • 42,176
  • 24
  • 124
  • 155
-1

Also for some of these features see stackless python.

Weasel
  • 77
  • 2