For some reason, I was under the impression that it was just called Timeout, but it doesn't seem to be.
Thanks!
For some reason, I was under the impression that it was just called Timeout, but it doesn't seem to be.
Thanks!
The timeout exception handling is explained in the Request Timer section of the docs:
A request handler has a limited amount of time to generate and return a response to a request, typically around 30 seconds. Once the deadline has been reached, the request handler is interrupted.
The Python runtime environment interrupts the request handler by raising a
DeadlineExceededError
, from the packagegoogle.appengine.runtime
. If the request handler does not catch this exception, as with all uncaught exceptions, the runtime environment will return an HTTP 500 server error to the client.The request handler can catch this error to customize the response. The runtime environment gives the request handler a little bit more time (less than a second) after raising the exception to prepare a custom response.
from google.appengine.runtime import DeadlineExceededError class MainPage(webapp.RequestHandler): def get(self): try: # Do stuff... except DeadlineExceededError: self.response.clear() self.response.set_status(500) self.response.out.write("This operation could not be completed in time...")
If the handler hasn't returned a response or raised an exception by the second deadline, the handler is terminated and a default error response is returned.
While a request can take as long as 30 seconds to respond, App Engine is optimized for applications with short-lived requests, typically those that take a few hundred milliseconds. An efficient app responds quickly for the majority of requests. An app that doesn't will not scale well with App Engine's infrastructure.
The DataStore has its own TimeOut exception
The
google.appengine.ext.db
package provides the following exception classes:[...]
exception Timeout()
Raised when the datastore operation exceeds the maximum amount of time allowed for datastore operations.
For datastore calls, the exception is google.appengine.ext.db.Timeout. For total (wall clock) duration exceeded, the exception is google.appengine.runtime.DeadlineExceededError. The DeadlineExceeded error is thrown 'soft' once, at which point you have a short time to return a response and exit; if you don't, it's thrown again, uncatchable, and your script is unceremoniously terminated.