姜戈/彗星(推):至少是邪恶的? [英] Django / Comet (Push): Least of all evils?

查看:38
本文介绍了姜戈/彗星(推):至少是邪恶的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了所有关于 Django 和 HTTP 推送的问题和答案.然而,关于如何实现所谓的彗星"功能的基本hello world",没有一个提供清晰、简洁、从头到尾的解决方案.

I have read all the questions and answers I can find regarding Django and HTTP Push. Yet, none offer a clear, concise, beginning-to-end solution about how to accomplish a basic "hello world" of so-called "comet" functionality.

第一个问题 (1):HTTP 根本(至少到目前为止)不是为此而设计的问题在多大程度上?所有潜在的解决方案本质上都是黑客吗?

First question (1): To what extent is the problem that HTTP simply isn't (at least so far) made for this? Are all the potential solutions essentially hacks?

2) 目前最好的解决方案是什么?

2) What's the best currently available solution?

  • 轨道?
  • 其他一些基于 Twisted 的解决方案?
  • 龙卷风?
  • node.JS?
  • XMPP 与 BOSH?

其他解决方案?

3) nginx push 模块如何参与这个讨论?

3) How does nginx push module play into this discussion?

4) 哪些解决方案需要替换典型的 mod_wsgi/nginx(或 apache)部署模型?他们为什么需要这个?无论如何,这是一个有利的过渡吗?

4) Which of these solutions require replacement of the typical mod_wsgi / nginx (or apache) deployment model? Why do they require this? Is this a favorable transition in any case?

5) 使用 Python 中已有的解决方案的优势有多大?

5) How significant are the advantages of using a solution that is already in Python?

Alex Gaynor 在 PyCon 2010 上的演讲,我刚刚在 blip.tv 上看过,非常精彩且内容丰富,但并没有特别具体地说明 Django 中 HTTP 推送的当前状态.他说的一件事给了我一些信心:Orbited 在抽象和模拟网络套接字的概念方面做得很好.因此,当 WebSockets 真正落地时,我们将处于过渡的好位置.

Alex Gaynor's presentation from PyCon 2010, which I just watched on blip.tv, is amazing and informative, but not terrifically specific on the current state of HTTP Push in Django. One thing that he said that gave me some confidence was this: Orbited does a good job of abstracting and simulating the concept of network sockets. Thus, when WebSockets actually land, we'll be in a good place for a transition.

6) HTML5 Websockets 与当前的解决方案有何不同?Gaynor 对从轨道过渡的难易程度的评估准确吗?

6) How does HTML5 Websockets differ from current solutions? Is Gaynor's assessment of the ease of transition from Orbited accurate?

推荐答案

我不敢相信我问这个问题已经六年多了.

I can't believe it's been over six years since I asked this question.

与 Django 的异步(以及相关的网络流量,例如 websockets)一直是我们社区中的许多人的渴望.在过去的几年里,我一直在努力解决这个问题.

Async with Django (and the associated network traffic, eg websockets) has been an itch for many of us in the community. I have taken these past few years, to among other things, scratch this itch.

hendrix

hendrix 是一个运行在 Twisted 上的 WSGI/ASGI 容器.这是一个主要由 5 位爱好者推动的项目,并得到了一些有远见的组织的帮助和资助.如今,它已在数十家(但不是数百家)公司中生产.

hendrix is a WSGI/ASGI conatiner that runs on Twisted. It has been a project mainly driven by 5 enthusiasts, with help and funding from some visionary organizations. It is in production today at dozens, but not hundreds, of companies.

我将留给您阅读文档以了解为什么它是解决此问题的最佳解决方案,但有几个要点:

I'll leave it to you to read the documentation to see why it's the best solution to this problem, but a few quick highlights:

  • 它基于 Twisted,无需了解或使用 Twisted 内部结构,但它们全部可用
  • 它正常工作",因为您不需要任何特殊的服务器或进程配置来从 Django(或 Pyramid 或 Flask)应用程序中执行异步和套接字流量
  • 它很可能与 Django Channels 标准 ASGI 向前兼容,并且在某些方面是第一个 ASGI 容器
  • 它附带了简单的 API,用于维护您的视图逻辑流并且易于进行单元测试.

请参阅我在 Django-NYC(在 Buzzfeedoffice) 了解更多关于为什么我认为这是这个问题的最佳答案的信息.

Please see this talk that I gave at Django-NYC (at the Buzzfeed offices) for more information about why I think this is the best answer to this question.

这篇关于姜戈/彗星(推):至少是邪恶的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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