user193476
user193476

Reputation:

Erlang-like concurrency for Python?

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.

Upvotes: 14

Views: 4249

Answers (7)

Will Weiss
Will Weiss

Reputation: 11

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.

Upvotes: 1

Warren Young
Warren Young

Reputation: 42343

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.

Upvotes: 7

fread2281
fread2281

Reputation: 1136

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

Upvotes: 0

monkut
monkut

Reputation: 43830

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.

Upvotes: 0

eris0xff
eris0xff

Reputation: 21

Try Axon / Kamaelia

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

Upvotes: 2

Weasel
Weasel

Reputation: 77

Also for some of these features see stackless python.

Upvotes: -1

Keith Gaughan
Keith Gaughan

Reputation: 22675

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.

Upvotes: 3

Related Questions