My backend job is working on the basis of cron job(every 4 hour).But it is terminated with out processing the data. The server log displays as following :
500 15377121ms 0kb instance=0 AppEngine-Google; (+http://code.google.com/appengine)
E 2012-10-05 01:50:18.044 Process terminated because the backend took too long to shutdown.
How to handle this kind of error in my program
Dealing with the same issue. Looked at the causes listed in the official docs. Memory consumption seems ok from statistics. Datastore contention issues are also handled in my code. Timeouts too. Changing the task mechanism to work in recoverable chunks seems the only way out.
After chasing this error for sometime now, it seems AppEngine development paradigm revolves around url handlers with limitations on time, memory etc. This is applicable to long running tasks too. I redid my long term task to be executed small tasks. Task queues triggered smaller tasks which inturn run, before finish queue the next task. Never failed even once!
The advantage is that taskqueuus have better failsafe/handover than just a huge cron job. One task failing does not mean the rest of the huge task list fail.
That error is generated when App Engine needs to shut your backend down but the backend fails to exit within 30 seconds. Some reasons why this might be happening are listed here. Depending on the type of error, App Engine may be sending your backend a notification of the impending shutdown, so it's a good idea to register a shutdown handler so you can gather more data about your app's state when this is about to happen.
If you are seeing this regularly there is probably a systematic explanation, such as your job's memory exceeding the maximum for the backend's class.