Note that there are some explanatory texts on larger screens.

plurals
  1. POGAE: Task on backend instance killed without warning
    primarykey
    data
    text
    <h2>TL;DR:</h2> <p>How can I work around this bug in Appengine: sometimes <code>is_shutting_down</code> returns False, and in a second or two, the instance is shut down?</p> <h2>Details</h2> <p>I have a backend instance on a Google Appengine application (Python). The backend instance is used to generate reports, which sometimes takes minutes or even hours to finish.</p> <p>To deal with unexpected shutdowns, I am watching for <code>runtime.is_shutting_down()</code> and store the report's intermediate state into DB when <code>is_shutting_down</code> returns True.</p> <p>Here's the portion of code where I check it:</p> <pre><code>from google.appengine.api import runtime #... def my_report_function(): #... # Check if we should interrupt and reschedule to avoid timeout error. duration_sec = time.time() - start too_long = MAX_SEC &lt; duration_sec is_shutting_down = runtime.is_shutting_down() log.debug('Does this report iteration need to wrap it up soon? ' 'Too long? %s (%s sec). Shutting down? %s' % (too_long, duration_sec, is_shutting_down)) if too_long or is_shutting_down: # save the state of report, reschedule next iteration, and return </code></pre> <p>Sometimes it works, but sometimes I see the following in the Appengine log:</p> <pre><code>D 2013-06-20 18:41:56.893 Does this report iteration need to wrap it up soon? Too long? False (348.865950108 sec). Shutting down? False E 2013-06-20 18:42:00.248 Process terminated because the backend took too long to shutdown. </code></pre> <p>Clearly, the 30-second timeout has not passed between the time when I checked the value returned by <code>runtime.is_shutting_down()</code>, and when Appengine killed the backend. </p> <p>Does anybody know why this is happening, and whether there is a workaround for this?</p> <p>Thank you in advance!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload