基本模块(谷歌应用程序引擎)的任务队列中出现最后期限超过错误



我使用的是python谷歌应用引擎SDK和Django框架。在我的情况下,任务队列抛出的最后期限超过错误

DeadlineExceededError:已超过响应HTTP请求的总截止日期。

尽管在基本缩放中使用任务队列,在基本或手动缩放中使用每个文档任务可以运行24小时。

任务是更新所有MySQL数据库值,所以很耗时。

通过在中发送投递请求启动任务

@api_view(['POST'])
def post_url(request):
 params= dict(.......)#some dict
 taskqueue.add(url='/tasks/gcm/gcm_all_user/',
                          params=params,
                          method="POST")
 return Response('Initiated task')

该任务由dispatch.yaml 调度到基本缩放模块

dispatch:
- url: "*/tasks/*"
  module: tasks

任务模块有一个url 的处理程序

application: some-application
module: tasks
version: 2
runtime: python27
api_version: 1
threadsafe: true
basic_scaling:
libraries:
- name: MySQLdb
  version: "latest"
handlers:
- url: /tasks.*
  script: app.wsgi.application

请任何人告诉我们如何使任务运行更长时间而不会出现截止日期超过错误。

任务可以根据需要运行,但HTTP请求有自己的截止日期。您可能需要重构任务中运行的代码——可能需要将一个大请求分解为一系列较小的请求。

相关内容

最新更新