Catching DeadlineExceededError

160 views
Skip to first unread message

gmalquestion

unread,
Aug 6, 2008, 12:03:54 PM8/6/08
to Google App Engine
A request in my app takes too long and it is terminated with a
DeadlineExceededError exception. I want to catch it and show some
civilized output if this happens.

The below code doesn't work. I uploaded the code and still nothing is
caught. The exception appears (debug is turned on) as before. What's
wrong with this approach?


from google.appengine.runtime import apiproxy_errors


...

def get(self):
try:
....
except apiproxy_errors.DeadlineExceededError:
self.response.out.write("hey")
return

...

Roberto Saccon

unread,
Aug 6, 2008, 1:06:41 PM8/6/08
to Google App Engine
look at rietveld code base, one of the things I have learnt there is:


# DeadlineExceededError can live in two different places
try:
# When deployed
from google.appengine.runtime import DeadlineExceededError
except ImportError:
# In the development server
from google.appengine.runtime.apiproxy_errors import
DeadlineExceededError


hope that helps

Roberto

gmalquestion

unread,
Aug 6, 2008, 1:54:02 PM8/6/08
to Google App Engine


On Aug 6, 7:06 pm, Roberto Saccon <rsac...@gmail.com> wrote:
> look at rietveld code base, one of the things I have learnt there is:
>
> # DeadlineExceededError can live in two different places

Thanks! It's working,

The name apiproxy should have tipped me off that it's for the dev
environment.

Ozgur Cem S.

unread,
Aug 6, 2008, 1:57:00 PM8/6/08
to Google App Engine

I danced around the "DeadlineExceededError" error recently, and I was
never able to trap the DeadlineExceededError. try: catch
DeadlineExceededError : never made it to my level so I can go around
it. (maybe I was doing something wrong...)

So the question is, can you trap DeadlineExceededError in the
application level?

Calvin Spealman

unread,
Aug 6, 2008, 4:25:22 PM8/6/08
to google-a...@googlegroups.com
Being able to catch it would defeat the purpose of it: stopping you
from taking up cpu time. Now, I do think that giving you enough
microseconds to make a civilized response to the user would be OK, but
after that an uncatchable makes sense.

--
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://ironfroggy-code.blogspot.com/

Ozgur Cem S.

unread,
Aug 6, 2008, 5:03:10 PM8/6/08
to Google App Engine
Calvin, I agree with you. I came to the same conclusion after a while.
My problem was happening during a bulk/insertion of records into the
datastore. Therefore, the visitor-user experience was not a concern of
mine, since that particular process is admin-only, and admins can
wait ;). All I needed was to trap, ifI exceeded the deadline, so I
can hop on a "redirect" and proceed the process in a separate request.
Oh well, I ended up limiting myself with 30 or so insertions at a
time, and redirect, and redirect and redirect.... and keep redirecting
until I have nothing else to insert. :)

This method worked pretty good for me so far on http://newsxperiment.appspot.com
. During periodical updates, I need to insert about 400 entries in the
datastore. And without splitting into seperate requests, there seems
to be no way to get that many :) records in there at one shot.

Cem
Reply all
Reply to author
Forward
0 new messages