Python Comet服务器 [英] Python Comet Server

查看:102
本文介绍了Python Comet服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个Web应用程序,该应用程序具有一个实时供稿(类似于Facebook的新闻供稿),我想通过长轮询机制对其进行更新。我了解使用Python,我的选择几乎是使用Stackless(从Comet wsgi示例构建)还是Cometd + Twisted。不幸的是,关于这些选项的文档很少,我无法在网上找到有关使用彗星的生产规模用户的良好信息。

I am building a web application that has a real-time feed (similar to Facebook's newsfeed) that I want to update via a long-polling mechanism. I understand that with Python, my choices are pretty much to either use Stackless (building from their Comet wsgi example) or Cometd + Twisted. Unfortunately there is very little documentation regarding these options and I cannot find good information online about production scale users of comet on Python.

有人在生产中成功地在Python上实现了彗星吗?系统?您如何去做,我在哪里可以找到实现我自己的资源?

Has anyone successfully implemented comet on Python in a production system? How did you go about doing it and where can I find resources to implement my own?

推荐答案

我建议您使用 StreamHub Comet Server -许多人使用它-我个人将它与我运行的两个Django网站一起使用。您将需要编写一点Java来处理流-我使用 Jython 做到了。前端代码是一些真正的简单Javascript:

I recommend you should use StreamHub Comet Server - its used by a lot of people - personally I use it with a couple of Django sites I run. You will need to write a tiny bit of Java to handle the streaming - I did this using Jython. The front-end code is some real simple Javascript a la:

StreamHub hub = new StreamHub();
hub.connect("http://myserver.com/");
hub.subscribe("newsfeed", function(sTopic, oData) { alert("new news item: " + oData.Title); });

文档非常好-在您尝试使用稀疏文档时,我遇到了类似的问题Cometd等。首先,我将阅读彗星入门和StreamHub ,下载并查看一些示例的工作方式,并在需要时引用API文档:

The documentation is pretty good - I had similar problems as you trying to get started with the sparse docs of Cometd et al. For a start I'd read Getting Started With Comet and StreamHub, download and see how some of the examples work and reference the API docs if you need to:

  • Javascript API JSDoc
  • Streaming from Java Javadoc

这篇关于Python Comet服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆