Google App Engine中的进度条 [英] Progress bar in Google App Engine

查看:79
本文介绍了Google App Engine中的进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Google App Engine应用程序,可以对远程API执行30-50次调用。每个电话都需要一秒钟左右的时间,因此整个操作可能需要一分钟。目前,我在我的站点的post()函数内的一个循环中执行此操作,因此在整个操作完成之前不会打印响应。毋庸置疑,该应用目前还不是很实用。



我想要做的是在操作开始后立即打印响应,然后在每个单独的API调用完成时更新它。我将如何实现这一目标?在桌面应用程序中,我只需启动一个定期更新前端的工作线程。 Google App Engine中是否有类似的机制?



我搜索了进度条和谷歌应用程序引擎,但大多数结果来自想要监视的人上传文件的进度。我的情况不同:服务器上正在执行耗时的任务,所以客户端无法监控其进度。 这家伙是我能找到的最接近的东西,但他工作在Java。 使用 =http://code.google.com/appengine/docs/python/taskqueue =nofollow> http://code.google.com/appengine/docs/python/taskqueue

  • 更改进程的逻辑以设置状态(可以使用memcache)
  • 每隔10秒使用AJAX查询memcache状态,或多或少,由您决定


  • I have a Google App Engine application that performs about 30-50 calls to a remote API. Each call takes about a second, so the whole operation can easily take a minute. Currently, I do this in a loop inside the post() function of my site, so the response isn't printed until the whole operation completes. Needless to say, the app isn't very usable at the moment.

    What I would like to do is to print the response immediately after the operation is started, and then update it as each individual API call completes. How would I achieve this? On a desktop application, I would just kick off a worker thread that would periodically update the front-end. Is there a similar mechanism in the Google App Engine?

    I googled around for "progress bar" and "google app engine" but most results are from people that want to monitor the progress of uploading a file. My situation is different: the time-consuming task is being performed on the server, so there isn't much the client can do to monitor its progress. This guy is the closest thing I could find, but he works in Java.

    解决方案

    1. Send the post logic to a task using http://code.google.com/appengine/docs/python/taskqueue
    2. Change the logic of the process to set a status (it could be using memcache)
    3. Using AJAX query memcache status each 10 seconds, more or less, it's up to you

    这篇关于Google App Engine中的进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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