0MQ 带有绿色线程?
我越来越喜欢 erlang,它的架构非常适合我的问题。与此同时,我仍然喜欢想象我可以将 erlang 进程与 erlang 进程混为一谈。 python 中的异步消息传递(我目前正在接受治疗以摆脱这种痴迷)。
在最近的一次狂欢中,我遇到了 0MQ 和 0MQ。我喜欢它的消息传递功能。对于 erlang/OTP 专家来说,这些可能是不言而喻的,但我只是一个谦虚的 Python 程序员(毫无疑问,我的心理医生会读到这个聪明的论点)。 0MQ 用户指南 声明它使用本机操作系统线程,而不是虚拟线程“绿色”线程。
有没有办法让 0MQ 与 eventlet/gevent 一起工作?
- 或者,我应该避免绿眼怪物并坚持使用单个 Python 应用程序线程,并由 0MQ 的消息队列和非阻塞 I/O 处理。 或者,我应该避免
或者,检查一下康复中心和康复中心。回到 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.
Is there a way to make 0MQ work with say eventlet/gevent?
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?
Or, check out of rehab & go back to erlang?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
回复陈旧的帖子,因为我也有同样的情况。我想我会分享我的想法。
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
零 MQ 现在可与 Eventlet 配合使用:
https://lists.secondlife.com/ Pipermail/eventletdev/2010-10月/000907.html
Zero MQ now works with Eventlet:
https://lists.secondlife.com/pipermail/eventletdev/2010-October/000907.html