开发者

How to implement automatic retries with GAE tasks?

开发者 https://www.devze.com 2023-03-25 03:27 出处:网络
Here is my code: class PublishPhotosHandler(webapp.RequestHandler): for argument in files_arguments: taskqueue.add(url=\'/upload\', params={\'key\': key})

Here is my code:

class PublishPhotosHandler(webapp.RequestHandler):
    for argument in files_arguments:
        taskqueue.add(url='/upload', params={'key': key})

class UploadWorker(webapp.RequestHandler):
    开发者_如何转开发def post(self):
        key = self.request.get('key')
        result = urlfetch.fetch(...)
        # how to return there an error, so the task will be retried?


If a task fails to execute (by returning any HTTP status code outside of the range 200–299), App Engine retries the task until it succeeds. By default, the system gradually reduces the retry rate to avoid flooding your application with too many requests, but schedules retry attempts to recur at a maximum of once per hour until the task succeeds.

raising any exception will cause a non-2XX status code, therefore raising any exception will cause the the task to be queued up again and retried.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号