Google App Engine Progress Bar

I have a Google App Engine application that makes about 30-50 calls to the remote API. Each call takes about a second, so the whole operation can take a minute. I am currently doing this in a loop inside the post () function of my site, so the response does not print until the whole operation is complete. Needless to say, the application is not very convenient at the moment.

I would like to do this to print the response immediately after the operation starts, and then update it at the end of each individual API call. How can i achieve this? In a desktop application, I would just start a workflow that periodically updates the interface. Is there a similar mechanism in the Google App Engine?

I searched for “progress” and “google engine”, but most of the results are from people who want to track the progress of a file upload. My situation is different: a time-consuming task is performed on the server, so the client cannot do so to track its progress. This guy is the closest I could find, but he works in Java.

+4
source share
3 answers
+3
source

You can immediately return from your message and do one of two things:

  • Survey your client every second or so to ask your service about its status
  • Use the channel API to push status updates to your client.
+3
source

Short version: use a task queue that is written to the memcache key as the operation progresses. Your page can either use the channel API or resubmit the server for a progress report.

Long version: in your message, you delegate a lot of work to the task. The task will periodically update the key that is in memcache. If you don’t have time to learn the channel API, you can make the page returned by your message, periodically provide the software with URLs in the application, which returns a progress report based on memcache data, and you can update the progress bar. When the work is completed, your script can go to the results page.

If you have the time, learning the channel API is worth the effort. In this case, the task will receive a channel marker so that it can communicate with the JavaScript channel client on your page without polling.

0
source

Source: https://habr.com/ru/post/1395922/


All Articles