My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
  Advanced search   Search tips   Subscriptions
Issue 2110: DeadlineExceededError not handled by RequestHandler.handle_exception
9 people starred this issue and may be notified of changes. Back to list
Status:  Accepted
Owner:  ----

Sign in to add a comment
Reported by thruflo, Sep 11, 2009
``google.appengine.runtime.DeadlineExceededError`` inherits from
``BaseException`` but the code in ``WSGIApplication.__call__`` that catches
exceptions and passes them to ``RequestHandler.handle_exception`` uses::

       # to call handler method
    except Exception, err:
       # pass err to handle_exception

Hence ``BaseExceptions`` are not caught.  You can patch this by importing
the file attached above ``DeadlineExceededError``::

    import deadline
    from google.appengine.runtime import DeadlineExceededError

However this is obviously less than ideal.  Is there a reason
``DeadlineExceededError`` inherits from ``BaseException``?
155 bytes   View   Download
Nov 18, 2009
#1 alexkon
I'm sure you could get a deeper explanation from some Python gurus but here's how I
understand it.

DeadlineExceededError inherits from BaseException and not from Exception to prevent
some obscure bugs when you catch all errors coming from a certain part of your app
with 'except Exception:'. Too often the code that is perfectly able to recover from
all normal errors in a certain part of your app does not do the right thing for
DeadlineExceededError. It is also easy to forget about the special kind of exceptions
such as DeadlineExceededError, SystemExit and KeyboardInterrupt when handling errors.

Unlike normal errors, you shouldn't swallow those special exceptions and try to
recover from them. Most of the time, you should clean up quickly and quit by
reraising the exception or otherwise. That's why catching everything with 'except:'
is usually wrong (use 'except Exception:' instead) and that's why those special
exceptions inherit from BaseException.

See also gvanrossum's comments in  issue 1409 . If DeadlineExceededError is swallowed
during an import, things can break badly.
Nov 14, 2010
Well, even if DeadlineExceededError is inherited from BaseException for a reason, DeadlineExceededError should be catched by WSGIApplication's handle_exception.
Jan 12, 2011
Project Member #3
(No comment was entered for this change.)
Status: Acknowledged
Labels: Component-ThirdParty
Apr 17, 2012
(No comment was entered for this change.)
Status: Accepted
Labels: -Component-ThirdParty Component-SDK
Sign in to add a comment

Powered by Google Project Hosting