使用 Python 在 Google App Engine 中实现 Comet / 服务器推送
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1285150/
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
Implement Comet / Server push in Google App Engine in Python
提问by Lev
How can I implement Comet / Server push in Google App Engine in Python?
如何在 Python 中的 Google App Engine 中实现 Comet / 服务器推送?
回答by Moishe Lettvin
We just announced the Channel API to do comet push with App Engine apps: http://googleappengine.blogspot.com/2010/05/app-engine-at-google-io-2010.html
我们刚刚发布了 Channel API 以使用 App Engine 应用程序进行彗星推送:http: //googleappengine.blogspot.com/2010/05/app-engine-at-google-io-2010.html
If you're at Google IO, I'll be talking about this at 1pm tomorrow (on the APIs track): http://code.google.com/events/io/2010/sessions/building-real-time-apps-app-engine-feed-api.html
如果你在 Google IO,我将在明天下午 1 点讨论这个(在 API 轨道上):http: //code.google.com/events/io/2010/sessions/building-real-time-apps -app-engine-feed-api.html
Here's the YouTube video of the session: http://www.youtube.com/watch?v=oMXe-xK0BWA
这是会议的 YouTube 视频:http: //www.youtube.com/watch?v=oMXe-xK0BWA
Hopefully last update! This is now released: code.google.com/appengine/docs/python/channel
希望最后更新!现已发布:code.google.com/appengine/docs/python/channel
回答by Alex Martelli
At this time, I would rule out doing Comet in App Engine (any language). Comet is based on long-lived HTTP connections, and App Engine will time out any single connection in about 30 seconds or so at most; it's hard to conceive of a worse match!
此时,我会排除在 App Engine(任何语言)中使用 Comet。Comet 基于长寿命的 HTTP 连接,App Engine 最多会在大约 30 秒左右的时间内超时任何单个连接;很难想象更糟糕的比赛!
回答by mainsocial
Comet (or something like it - XMPP API) is on the google app engine roadmap. For now, stay away.
Comet(或类似的东西 - XMPP API)在谷歌应用引擎路线图上。现在,远离。
回答by Uriel Katz
30 seconds is more than enough; either way you should return a no-op message when a time passed and no new events occur.
30秒绰绰有余;无论哪种方式,当时间过去并且没有新事件发生时,您都应该返回一条无操作消息。
This prevents client timeouts and is done by everybody who does comet.
这可以防止客户端超时,并且由执行 Comet 的每个人完成。
Just send the request, and on the server make it wait until an event or timeout after 25 seconds.
只需发送请求,然后在服务器上使其等待 25 秒后发生事件或超时。
回答by kvdb
Looking inside the App Engine 1.3.8-pre release, I see the Channel API service stub and more code. So it looks like we can start trying it out locally.
查看 App Engine 1.3.8-pre 版本的内部,我看到了 Channel API 服务存根和更多代码。所以看起来我们可以开始在本地尝试了。
回答by Robber
Google App Engine supports server push using the Channel API since 2nd December.
自 12 月 2 日起,Google App Engine 支持使用 Channel API 进行服务器推送。