Python 中 Comet 的最新推荐?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1514899/
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
The latest recommendation for Comet in Python?
提问by John R
I'm going to be implementing Comet in Python (even though I hear good things about erlycomet I'm not thrilled about supporting an Erlang-based web server in addition to everything else in our back end). I've found several possibilities:
我将在 Python 中实现 Comet(尽管我听到了关于 erlycomet 的好消息,但我对支持基于 Erlang 的 Web 服务器以及我们后端的所有其他内容并不感到兴奋)。我发现了几种可能性:
- Diesel
- Tornado
- Twisted-comet
- Orbited(uses twisted)
(there are also some other choices that interface with Java servers, but I'm not interested in those)
(还有一些其他选择与 Java 服务器接口,但我对这些不感兴趣)
Can somebody make a recommendation among these implementations, considering performance, community, and ease of implementation?
考虑到性能、社区和实施的难易性,有人可以在这些实施中提出建议吗?
回答by Tom Leys
I am personally using Orbited, both because I am already using Twisted and because it seems mature. Twisted has a nice long history with many users, especially in comparison to Diesel and Tornado. Orbited is indeed built on Twisted.
我个人在使用 Orbited,因为我已经在使用 Twisted 并且因为它看起来很成熟。Twisted 拥有许多用户的悠久历史,尤其是与 Diesel 和 Tornado 相比。Orbited 确实建立在 Twisted 之上。
There is a good blog entry covering an end-to-end orbit solution here. It sends data from a python script to a STOMP server (MorbidQ) to Orbited to Javascript - rendering that data as a graph.
这里有一篇很好的博客文章,涵盖了端到端的轨道解决方案。它将数据从 python 脚本发送到 STOMP 服务器 (MorbidQ) 到 Orbited 到 Javascript - 将该数据呈现为图形。
Tornado seems pretty new to the scene, I couldn't find twisted-comet and I hadn't heard of diesel. I particularly like the way that Orbited can forward any sort of tcp/ip but makes it easy to hook javascript clients in with a message passing STOMP backend.
龙卷风似乎对现场很陌生,我找不到扭曲彗星,也没有听说过柴油。我特别喜欢 Orbited 可以转发任何类型的 tcp/ip 的方式,但可以轻松地将 javascript 客户端与传递 STOMP 后端的消息挂钩。
回答by clemesha
I'd recommend Orbited if you're looking to write a Comet app.
如果您想编写 Comet 应用程序,我会推荐 Orbited。
What makes Comet more complex to implement (than making an Ajax app, say), is that you need both the client (a Comet javascript client) and the server (an asynchronous webserver like Twisted) working in conjunction, and this is what you get with Orbited - both the javascript client and the server.
使 Comet 实现起来更复杂的原因(比方说制作 Ajax 应用程序)是您需要客户端(Comet javascript 客户端)和服务器(像 Twisted 这样的异步网络服务器)协同工作,这就是您所得到的使用 Orbited - javascript 客户端和服务器。
Both Tornado and Diesel provide mainly the async server part, but are missing the important client javascript code.
Tornado 和 Diesel 都主要提供异步服务器部分,但缺少重要的客户端 javascript 代码。
Plus, there is a pretty good community around Orbited, and several people are building cool apps with it, this pages shows a couple of those apps: http://orbited.org/wiki/Sites
此外,Orbited 周围有一个非常好的社区,有几个人正在用它构建很酷的应用程序,这个页面展示了其中的几个应用程序:http: //orbited.org/wiki/Sites
回答by Juanjo Conti
I've also been using Twisted. But instead of Orbited, I'm using Nevow.Athena. It's really simple: learn more reading the LiveElement tutorial.
我也一直在使用 Twisted。但我使用的是 Nevow.Athena,而不是 Orbited。这真的很简单:阅读LiveElement 教程了解更多信息。
回答by oberstet
Are you settled on Comet? Why not WebSockets? If the latter is also an option, I'd like to refer https://github.com/tavendo/AutobahnPythonwhich implements WebSockets in Twisted (documentation is available on http://autobahn.ws/python). It is standards compliant, has message-based basic API and advanced API for frame-based/streaming processing and many more goodies.
你确定在彗星上吗?为什么不是 WebSockets?如果后者也是一个选项,我想参考https://github.com/tavendo/AutobahnPython,它在 Twisted 中实现了 WebSockets(文档可在http://autobahn.ws/python 上找到)。它符合标准,具有基于消息的基本 API 和用于基于帧/流处理的高级 API 以及更多优点。
回答by autholykos
My answer to this questionprovides an example of server push using the autobahnlibrary which IMHO is so far the most user friendly WebSocket framework powered by Twisted. Also a JS implementation is available as well as Android.
我对这个问题的回答提供了一个使用高速公路库的服务器推送示例,恕我直言,这是迄今为止由 Twisted 提供支持的最用户友好的 WebSocket 框架。还有一个 JS 实现和 Android 一样可用。
Comet is fully replaced by WebSocket and you should consider using the latter unless you plan to support IE8 and older
Comet 已被 WebSocket 完全取代,除非您计划支持 IE8 及更早版本,否则您应该考虑使用后者
回答by Fred
Tornado works fine you can fine a websockets example here : https://github.com/Introduction-to-Tornado/Introduction-to-Tornado/tree/master/asynchronous_web_services/websockets
Tornado 工作正常,您可以在这里创建一个 websockets 示例:https: //github.com/Introduction-to-Tornado/Introduction-to-Tornado/tree/master/asynchronous_web_services/websockets