> I don't think you can do this. When you get a DeadlineExceededError > you only have a very short amount of cpu time left -- enough to return > a simple response to the client, but not enough to queue a new task.
http://code.google.com/appengine/articles/deferred.html contains sample code that queues a task in response to a DeadlineExceededError . (defer is a task queue wrapper.) Not only does this example queue a task after a DeadlineExceededError, it also does a db.put and a db.delete; look at _batch_write. I'm not surprised that there's enough time to do queue a task but I am surprised that there's also enough time to do a put and a delete. On Dec 12, 4:23 am, Stephen <[email protected]> wrote: > On Dec 10, 11:44 am, Alex Popescu > > <[email protected]> wrote: > > > Here is the scenario in which I'm seeing this error: > > > - I have a set of tasks that are executed > > > - the tasks are expensive so sometimes they may reach the > > DeadlineExceededError > > > - in case the DeadlineExceededError occurs, I am attempting to create > > a new task to signal that processing was not completed and should > > continue at a later moment > > I don't think you can do this. When you get a DeadlineExceededError > you only have a very short amount of cpu time left -- enough to return > a simple response to the client, but not enough to queue a new task. > > > While I could probably code around this issue, it will definitely make > > my app code more messy and complex. Right now things are clear: > > > - there is a list of objects that must be processed > > > - once new objects get appended to that list a new task is created for > > taking care of them > > > - if the task cannot empty the list of objects to be processed it is > > scheduling a new task to continue the processing later > > You could try making your batch size smaller. > > If a task does not return a 200 success response, it will be retried. > You could code your task so that if it only manages to process some of > the list, when it is run again after returning a non-200 response it > picks up where it left off and processes the remaining items in the > list. > > > Can anyone explain the meaning of the CancelledError? I read the > > documentation and I must confess that I'm not very sure what triggers > > it (at least I don't agree it is "explicitly"). > > This is probably your second task being cancelled after your > DeadlineExceededError. -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
