哪个 Actor 模型库/框架适用于 python 和 Erlang-like?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3423447/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 10:59:59  来源:igfitidea点击:

Which Actor model library/framework for python and Erlang-like?

pythonerlangactorpython-stackless

提问by daitangio

I am looking for an easy-to-learn Actor library or framework for Python 2.x. I have tried Candygram and Twisted but I did not like them. I'd like something that will be easy to extend to suppero Greenlet (= stackless python).

我正在为 Python 2.x 寻找易于学习的 Actor 库或框架。我试过 Candygram 和 Twisted,但我不喜欢它们。我想要一些易于扩展到 supero Greenlet (= stackless python) 的东西。

  • Candygram is too old.
  • Twisted is too complicated.
  • Gevent: it is unclear if it can support Actors model.
  • Candygram 太旧了。
  • 扭曲太复杂了。
  • Gevent:不清楚是否支持Actors模型。

What do you suggest?

你有什么建议?

采纳答案by Denis Bilenko

To make actors with gevent, use a Greenletsubclass with embedded gevent.queue.Queueinstance used as an inbox. To read a message from the inbox, simply get()from the queue. To send a message to an actor, putit into that actor's queue.

要使用gevent制作演员,请使用带有嵌入式gevent.queue.Queue实例的Greenlet子类用作收件箱。要从收件箱中读取消息,只需从队列中get()即可。要向演员发送消息,请将其放入该演员的队列中。

Read about subclassing Greenlet here.

在此处阅读有关子类化 Greenlet 的信息

If you need help with writing the Actor class, feel free to ask the mailing list.

如果您在编写 Actor 类方面需要帮助,请随时询问邮件列表

回答by Michael

This tutorialhas a simple and working example for actors with gevent. Basically it's exactly as Denis already described.

教程为带有 gevent 的 actor 提供了一个简单且有效的示例。基本上它和丹尼斯已经描述的完全一样。

回答by jrydberg

I would take a look at this: https://bitbucket.org/fzzzy/python-actors

我会看看这个:https: //bitbucket.org/fzzzy/python-actors

It's pretty much a straight clone of the Erlang actor model, with "saved" messages queue, links and everything.

它几乎是 Erlang 演员模型的直接克隆,带有“已保存”的消息队列、链接和所有内容。

回答by David

PARLEYand Pykkaare listed on this Wikipedia Actor Model pageso you might want to look into one of those.

帕利Pykka列出这对维基百科的演员Model页面,所以你可能要考虑其中的一个。

Pykka seems to be actively developed (1.0.1 released in Dec 2012) whereas PARLEY hasn't had a release since 2007 (and is still listed as beta) . Pykka claims to be insipired by Akkaonly in name is not a simply a python port.

Pykka 似乎正在积极开发(1.0.1 于 2012 年 12 月发布),而 PARLEY 自 2007 年以来一直没有发布(并且仍被列为测试版)。Pykka 声称受Akka启发只是名义上不是简单的 Python 端口。

回答by Luca Sbardella

Check out pulsar, it is a concurrent framework for python which uses the actor model as source of parallel execution.

查看pulsar,它是 Python 的并发框架,它使用 actor 模型作为并行执行的源。

回答by beardedeagle

I know this question is a bit dated but here is another actor resource for python now:

我知道这个问题有点过时了,但现在这里是 python 的另一个 actor 资源:

https://github.com/godaddy/Thespian

https://github.com/godaddy/Thespian

Documentation can be found here:

文档可以在这里找到:

http://godaddy.github.io/Thespian/doc/

http://godaddy.github.io/Thespian/doc/

EDIT:

编辑

The primary author of this library has since left GoDaddy and forked the repo:

此库的主要作者已离开 GoDaddy 并分叉了该存储库:

https://github.com/kquick/Thespian

https://github.com/kquick/Thespian

New docs can be found here:

可以在此处找到新文档:

http://thespianpy.com/doc/

http://thespianpy.com/doc/