I am attempting to customize my application response to a
DeadlineExceededError.  I am able to catch the exception, but my
custom response is not getting through.  Instead I get the default
"502 Server Server Error" page even after clearing the response and
writing a custom one.  It seems as if the GAE is allowing time for
cleanup, but ignoring anything written to the response object.  Is
anyone doing this successfully?

More details...

The GAE documentation states that you can customize your applications
response to a DeadlineExceededError with the following example code
(see http://code.google.com/appengine/docs/python/runtime.html):

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...")

I have the following handler for "/test" on my App:

class TestPage(webapp.RequestHandle):
    def get(self):
        try:
            sleeptime = int(self.request.get('sleep'))
            if(sleeptime == 0):
                logging.info("Programatically raising
DeadlineExceededError")
                raise DeadlineExceededError
            else:
                time.sleep(sleeptime)

        except DeadlineExceededError:
            logging.error("Ran out of time.")
            self.response.clear()
            self.response.set_status(500)
            self.response.out.write("This operation could not be
completed in time...")

        logging.info("About to write normal result message")
        self.response.out.write("This is the normal result message")

When I request "/test?sleep=30" I get the "502 Server Server Error"
page and the in my logs:

(E) 02-22 09:31PM 05.652
Ran out of time.
(I) 02-22 09:31PM 05.653
About to write normal result message

When I request "/test?sleep=0" I get the expected "This operation
could not be completed in time..." message page.  Anyone know what's
up with this?  Thanks for any help!

  -Lenza


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to