简体   繁体   English

在谷歌应用引擎(python)中实时更新图表

[英]Live updating charts in google app engine (python)

I want the graph to update after every specific interval of time (say 10 seconds). 我希望图表在每个特定的时间间隔(比如10秒)后更新。 During this time the app would either do processing to determine the upcoming value of graph (which would include acquiring information from certain web-pages using urlfetch) or remain idle. 在此期间,应用程序将进行处理以确定即将到来的图形值(其中包括使用urlfetch从某些网页获取信息)或保持空闲。

Is it possible to make such a graph in GAE? 是否可以在GAE中制作这样的图表? If so I'll highly appreciate if someone can guide me to the right direction. 如果是这样的话,如果有人能引导我走向正确的方向,我将非常感激。 Also how would the normal 1 minute deadline per app request apply here (and basically how to avoid it? since i would like the graph to remain updating for some time say 2-5 minutes..) 此外,每个应用程序请求的正常1分钟截止时间如何适用于此(基本上如何避免它?因为我希望图表在一段时间内保持更新,比如2-5分钟..)

Two thinks to do: 两个人认为:

  1. Do the data processing on server: use Cron to invoke your data-processing code . 在服务器上进行数据处理: 使用Cron调用数据处理代码 Requests invoked by Cron have 10min deadline. Cron调用的请求有10分钟的截止日期。

  2. Client side reload - there are many ways to do it: 客户端重新加载 - 有很多方法可以做到:

    a. 一种。 The most simple way - make HTML page reload itself at regular intervals: 最简单的方法 - 使HTML页面定期重新加载:

     <META HTTP-EQUIV="refresh" CONTENT="15"> 

    b. Use javascript timer to update only a part of page: 使用javascript计时器仅更新页面的一部分:

     setTimeout("javascript statement to update part of page",milliseconds); 

    c. C。 Use Channels API , so that data-processing task, when finished, notifies clients to reload the page. 使用Channels API ,以便数据处理任务完成后,通知客户端重新加载页面。

Options a. 选项a。 and b. 和b。 are simple to implement, but they just blindly update the page even if there is no new data to display. 实现起来很简单,但即使没有要显示的新数据,它们也只是盲目地更新页面。 They also update at regular intervals, instead of when there is new data to display. 它们也会定期更新,而不是在有新数据显示时更新。 You can use one of those if there is only a few clients using this page. 如果只有少数客户使用此页面,您可以使用其中一个。

Options c. 选项c。 it the hardest to implement, but is IMO the right way, since it only reloads the page when there is actually something new to display. 它是最难实现的,但IMO是正确的方式,因为它只会在实际显示新内容时重新加载页面。 You should use this option if you have a lot of clients using this page. 如果您有很多客户使用此页面,则应使用此选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM