Hide Dead Line Exceeded Errors from User (Python)

82 views
Skip to first unread message

Brandon Wirtz

unread,
Jan 23, 2012, 6:05:45 AM1/23/12
to google-a...@googlegroups.com

You Just Died a Horrible death your app timed out, the world is ending around you.  Deal with it. No, seriously, handle the exception and try it again it will work eventually.

 

Here is the code.  

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 

 

from google.appengine.runtime import DeadlineExceededError

 

class MainPage(webapp.RequestHandler):

    def get(self):

        try:

            # Do stuff...

 

        except DeadlineExceededError:

            self.response.clear()

            self.response.headers['Location'] = response.geturl()

            self.response.set_status(302)

 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 

 

Feel free to send Dancing Girls, Mermaids, Mountain Dew, or whatever else if this makes all your DEE issues go away.  We are testing this for keeping free apps free. Server might get slow, but pages will always load. (unless you get 7 302’s then most browsers give up.) 

 

 

 

 

Joshua Smith

unread,
Jan 23, 2012, 7:41:57 AM1/23/12
to google-a...@googlegroups.com
Cute. Won't work for a POST, though. Also, I wonder if a short sleep might be in order. Another variation would be to check how much wallclock time has passed, and if it's not a lot, just return get(self) (which would work for POST).

-- 
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-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.

Brandon Wirtz

unread,
Jan 23, 2012, 11:33:11 AM1/23/12
to google-a...@googlegroups.com

You can’t sleep, it won’t work.  Post should work in most modern browsers they will forward post data. Works in IE and chrome.

Joshua Smith

unread,
Jan 23, 2012, 12:12:43 PM1/23/12
to google-a...@googlegroups.com
I'm surprised that redirect would work on POST. The RFC http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html says:

If the 302 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.

It not only says "MUST NOT" but it says it in CAPITAL LETTERS :)

Brandon Wirtz

unread,
Jan 23, 2012, 12:47:35 PM1/23/12
to google-a...@googlegroups.com

If the url changes Browsers get upset.  If the url is the same most do not.

 

You are right, there are limitations this is not a silver bullet but it will help a lot. 

 

If your post data was minimal you could convert it to get on the redirect.

 

OR… if you are really sneaky…

 

Log an error, put the post data on the error with a GUID, Redirect to a request with the guid.  Grab the error from the Logs.

 

(logs work even when datastore doesn’t)

C Sowa

unread,
Jan 23, 2012, 10:45:32 PM1/23/12
to google-a...@googlegroups.com
FYI, if you redirect a post with a 307 status, it will re-post the data to the new URL, any domain.  Or at least this worked for me for years.  In today's more locked-down environment, I haven't tried.  Worth a shot.

Brandon Wirtz

unread,
Jan 24, 2012, 8:15:03 AM1/24/12
to google-a...@googlegroups.com

I’ll test that. I don’t know if Curl, and Fetch and other things follow 307s or not.  Browsers do.

 

Both our ways are hacks, but if they work for 99% of users (with either method) 95% becomes 99.5%

 

 

From: google-a...@googlegroups.com [mailto:google-a...@googlegroups.com] On Behalf Of C Sowa
Sent: Monday, January 23, 2012 7:46 PM
To: google-a...@googlegroups.com
Subject: Re: [google-appengine] Hide Dead Line Exceeded Errors from User (Python)

 

FYI, if you redirect a post with a 307 status, it will re-post the data to the new URL, any domain.  Or at least this worked for me for years.  In today's more locked-down environment, I haven't tried.  Worth a shot.

--

You received this message because you are subscribed to the Google Groups "Google App Engine" group.

To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/tqBQBIJFfTgJ.

Robert Kluin

unread,
Jan 24, 2012, 2:32:32 PM1/24/12
to google-a...@googlegroups.com
I would seriously consider including a logging call so I knew where
the deadline was actually getting hit. Masking errors is a great way
to miss problems.

Also, for quite a long time I've set lower deadlines on individual RPC
calls. This frequently allows you to quickly hit an RPC deadline and
try again within the first request; in a high percentage of cases it
will succeed the second try.


Robert

> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.

Brandon Wirtz

unread,
Jan 24, 2012, 6:43:58 PM1/24/12
to google-a...@googlegroups.com
If we log things, we can't pretend we were unaware of a problem.

-----Original Message-----
From: google-a...@googlegroups.com
[mailto:google-a...@googlegroups.com] On Behalf Of Robert Kluin
Sent: Tuesday, January 24, 2012 11:33 AM
To: google-a...@googlegroups.com
Subject: Re: [google-appengine] Hide Dead Line Exceeded Errors from User
(Python)

Reply all
Reply to author
Forward
0 new messages