0MQ 带有绿色线程?

发布于 2024-09-13 22:17:55 字数 538 浏览 2 评论 0原文

我越来越喜欢 erlang,它的架构非常适合我的问题。与此同时,我仍然喜欢想象我可以将 erlang 进程与 erlang 进程混为一谈。 python 中的异步消息传递(我目前正在接受治疗以摆脱这种痴迷)。

在最近的一次狂欢中,我遇到了 0MQ 和 0MQ。我喜欢它的消息传递功能。对于 erlang/OTP 专家来说,这些可能是不言而喻的,但我只是一个谦虚的 Python 程序员(毫无疑问,我的心理医生会读到这个聪明的论点)。 0MQ 用户指南 声明它使用本机操作系统线程,而不是虚拟线程“绿色”线程。

  1. 有没有办法让 0MQ 与 eventlet/gevent 一起工作?

  2. 或者,我应该避免绿眼怪物并坚持使用单个 Python 应用程序线程,并由 0MQ 的消息队列和非阻塞 I/O 处理。 或者,我应该避免
  3. 或者,检查一下康复中心和康复中心。回到 erlang?

I've grown to like erlang, and it's a great (cough) architectural fit to my problem. Meanwhile I still like to imagine that I can kludge erlang processes & asynchronous message passing in python (I am currently in therapy to rid myself of this obsession).

During a recent binge I came across 0MQ & I like its messaging features. These may be self-evident to an erlang/OTP expert, but I'm just a humble python programmer (my shrink will no doubt get to read this clever argument). The 0MQ user-guide states that it uses native OS threads, and not virtual "green" threads.

  1. Is there a way to make 0MQ work with say eventlet/gevent?

  2. Or, should I avoid the green-eyed monster and stick to a single Python app thread, with non-blocking I/O handled by 0MQ's message queuing & its own (skilled) use of native threads?

  3. Or, check out of rehab & go back to erlang?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜警司 2024-09-20 22:17:55

回复陈旧的帖子,因为我也有同样的情况。我想我会分享我的想法。

1:看起来所有繁重的工作已经完成: https://github.com/traviscline/gevent -zeromq 将 gevent 循环与非阻塞 zmq 套接字集成在一起,甚至还实现了一些 Cpython 加速。它似乎(在撰写本文时)维护得相当好。

2:这取决于;如果您正在编写可以使用 zmq 而无需大量外部事件逻辑的东西,那么您应该只使用 zmq。如果OTOH您需要与其他协议集成,您可能需要使用gevent(或者可能是twisted,尽管它现在根本没有可用的zmq)。我的项目通常需要多个协议(即:私有队列管理器、公共 http、公共 https、私有 memcache 等),因此我正在研究切换到 gevent,以便比我目前最喜欢的:twisted 更快的项目周转。

3:您可能想完全跳过 zmq 并与现有的基于 erlang 的解决方案(如rabbitMQ)集成; zmq的性能优势可能没有你想象的那么重要,然后你就有了一个erlang消息队列,可以轻松地与python和现有库集成。

另请参阅:第二人生 wiki 上的消息队列比较

Responding to a stale thread because I am kind of in the same boat. Thought I would share my thoughts.

1: It looks like all the heavy lifting has already been done: https://github.com/traviscline/gevent-zeromq has integrated the gevent loop with a nonblocking zmq socket and even some Cpython speedups. It also seems to be (at the time of this writing), reasonably well maintainted.

2: It depends; if you are writing something that can use zmq without a ton of external event logic, then you should just use zmq. If OTOH you need to integrate with other protocols, you may want to use gevent (or twisted perhaps, although it has no workable zmq now at all). My projects generally require multiple protocols (ie: private queue manager, public http, public https, private memcache, etc), so I am investigating switching to gevent for quicker project turnaround than my current favorite: twisted.

3: You may want to skip zmq entirely and integrate with an existing erlang based solution like rabbitMQ; the performance advantages of zmq may not be as important as you think, and then you have an erlang message queue that easily integrates with python with existing libraries.

Also see: Messsage Queue comparison at second life wiki

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文