Managing DeadlineExceededError within the taskqueue

138 views
Skip to first unread message

Greg Tracy

unread,
Oct 28, 2009, 10:31:43 PM10/28/09
to Google App Engine

I'm running an email distribution list that utilizes the taskqueue to
send out emails to individuals recipients. Periodically, I'm getting
DeadlineExceededError when the Mail.send() call doesn't return fast
enough. (This alone would be nice to avoid, but that's for another
day).

File "/base/python_lib/versions/1/google/appengine/api/
apiproxy_rpc.py", line 111, in CheckSuccess
raise self.exception
DeadlineExceededError: The API call mail.Send() took too long to
respond and was cancelled.

I've tried catching the exception without success. This is what I've
tried...

from google.appengine.runtime import DeadlineExceededError
class EmailWorker(webapp.RequestHandler):
def post(self):

try:
# send email
message = mail.EmailMessage
()
# setup message properties...
apod_message.send()

except DeadlineExceededError:
logging.info("DeadlineExceededError exception!?! Try to
set status and return normally")
self.response.clear()
self.response.set_status(200)
self.response.out.write("Task took to long for %s - BAIL!"
% email)

Right now, this results in the task failing (no exception caught), but
the mail message succeeding. Then the task gets re-queued and the
recipient gets the message for the second time.

Thoughts?

djidjadji

unread,
Oct 29, 2009, 4:37:39 AM10/29/09
to google-a...@googlegroups.com
There are two definitions of DeadlineExceededError

google/appengine/runtime/__init__.py
class DeadlineExceededError(BaseException):
"""Exception raised when the request reaches its overall time limit.
Not to be confused with runtime.apiproxy_errors.DeadlineExceededError.
That one is raised when individual API calls take too long.
"""

google/appengine/runtime/apiproxy_errors.py
class DeadlineExceededError(Error):
"""Raised by APIProxy calls if the call took too long to respond."""


2009/10/29 Greg Tracy <greg....@att.net>:

Greg Tracy

unread,
Oct 29, 2009, 2:34:56 PM10/29/09
to Google App Engine

I tried to use the apiproxy_errors version but GAE couldn't find it
during excecution...

File "/base/data/home/apps/apodemail/1.337377943281842397/main.py",
line 191, in post
except apiproxy_errors.DeadlineExceededError:
NameError: global name 'apiproxy_errors' is not defined


Thanks for your suggestions.



On Oct 29, 3:37 am, djidjadji <djidja...@gmail.com> wrote:
> There are two definitions of DeadlineExceededError
>
> google/appengine/runtime/__init__.py
> class DeadlineExceededError(BaseException):
>   """Exception raised when the request reaches its overall time limit.
>   Not to be confused with runtime.apiproxy_errors.DeadlineExceededError.
>   That one is raised when individual API calls take too long.
>   """
>
> google/appengine/runtime/apiproxy_errors.py
> class DeadlineExceededError(Error):
>   """Raised by APIProxy calls if the call took too long to respond."""
>
> 2009/10/29 Greg Tracy <greg.tr...@att.net>:

djidjadji

unread,
Oct 29, 2009, 8:16:12 PM10/29/09
to google-a...@googlegroups.com
Did you include?

from google.appengine.runtime import apiproxy_errors

2009/10/29 Greg Tracy <greg....@att.net>:

Greg Tracy

unread,
Oct 31, 2009, 11:50:12 AM10/31/09
to Google App Engine
no... i was using the wrong import.

thank you @djidjadji

On Oct 29, 7:16 pm, djidjadji <djidja...@gmail.com> wrote:
> Did you include?
>
> from google.appengine.runtime import apiproxy_errors
>
> 2009/10/29 Greg Tracy <greg.tr...@att.net>:
Reply all
Reply to author
Forward
0 new messages