我应该使用什么Python Web框架与GWT来从Python后端流式传输KML? [英] What Python Web Framework should I use with GWT to stream KML from Python Back-end?

查看:144
本文介绍了我应该使用什么Python Web框架与GWT来从Python后端流式传输KML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用Python 2.7编写的长时间运行的进程,我想在生成KML文件时将KML文件异步发送到我的GWT应用程序。

我一直在试图确定我可以用什么Python web框架作为Python进程的后端,它可能允许webapp托管在Google AppEngine上。

我能够使用Cherrypy编写一个简单的python web服务器,它使用http请求将使用JSON的kml从后端发送到GWT;不过,我希望这些文件在生成时发送到GWT,因为它们之间可能有几分钟的时间。什么将是一个相对简单但有效的方法来实现这一目标? (Comet?Long-polling?Websockets?)

在研究了更多的python web框架之后,我开始尝试Tornado,因为它是非阻塞的,好像可以返回数据因为它可能使用如此答案中所述的长轮询。但是,它看起来像GAE要求WSGI不允许Tornado Web服务器是非阻塞的。

我已阅读类似问题的答案,例如这一个。但是,我不确定在web框架,GWT或GAE中的更新是否改变了今天的最佳选择,或者这些答案中的一些是否适用于我的案例。



你会推荐什么样的Python Web框架我使用长轮询或其他方法相对简单地将数据发送到我的异步GWT应用程序?我可以在GAE上使用这个Web框架,还是需要使用别的东西?

解决方案

如果我正确地理解了这个问题,您可能不需要任何特殊的框架,您可以使用您的解决方案来解决它: Channel API

使用Tasks API,您可以执行长时间任务,任务完成后您可以收到通知。您可以将其与Channel API结合使用,以在特定任务完成时将消息直接推送到客户端。

您也可以使用延期库来简化您的任务,甚至可以使用 PubNub 进行推送通知,因为设置是更容易,而且您可以同时拥有多个订阅者。


I have a long-running process written in Python 2.7 that I would like to send KML files to my GWT application asynchronously as the KML files are generated.

I have been trying to determine what Python web framework I could use as the back-end with the Python process that could possibly allow the webapp to be hosted on Google AppEngine.

I was able to write a simple python webserver using Cherrypy that sent the kml using JSON from the back-end to GWT using an http request; however, I would like the files to be sent to GWT as they are generated since it may be several minutes between each one. What would be a relatively simple but effective way to achieve this? (Comet? Long-polling? Websockets?)

After researching more python web frameworks, I started experimenting with Tornado because it is non-blocking and seems like it could return data as it is generated possibly using long-polling as mentioned in this answer. However, it looks like GAE requires WSGI which would not allow a Tornado webserver to be non-blocking.

I have read answers to similar questions such as this one. However, I am not sure if updates in web frameworks, GWT, or GAE has changed what is the best option today, or whether some of these answers apply to my case.

What Python web framework would you recommend I use to send data to my asynchronous GWT app using long-polling or another method relatively simply? Could I use this web framework with GAE, or would I need to use something else?

解决方案

If I understood the problem correctly you might don't need any special framework and you can solve it with what you have: Tasks API and Channel API.

With Tasks API you can perform long task and when the task is complete you can get a notification. You can combine it with the Channel API to push messages directly to the client when a particular task is complete.

You could use also the deferred library to simplify your life with tasks and maybe even using the PubNub for your push notifications, since the setup is easier and you can have many subscribers at the same time.

这篇关于我应该使用什么Python Web框架与GWT来从Python后端流式传输KML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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