开发者

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.


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.


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.


Try Axon / Kamaelia

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


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.


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.


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


Also for some of these features see stackless python.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜