javascriptpythongoogle-app-enginechartslive-update

Live updating charts in google app engine (python)


I want the graph to update after every specific interval of time (say 10 seconds). 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.

Is it possible to make such a graph in 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..)


Solution

  • Two thinks to do:

    1. Do the data processing on server: use Cron to invoke your data-processing code. Requests invoked by Cron have 10min deadline.

    2. Client side reload - there are many ways to do it:

      a. The most simple way - make HTML page reload itself at regular intervals:

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

      b. Use javascript timer to update only a part of page:

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

      c. Use Channels API, so that data-processing task, when finished, notifies clients to reload the page.

    Options a. and 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. 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. You should use this option if you have a lot of clients using this page.