GAE Python - Cron 作业不会在目标模块上执行



我刚刚在 GAE 上实现了模块,并尝试从某个模块运行 Cron 作业。我的app.yaml在顶部有以下值:

application: myapp
module: default
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
#all handlers

我尝试激活的模块的 reporting.yaml 具有以下设置:

application: myapp
module: reporting
version: 1
instance_class: B4
runtime: python27
api_version: 1
threadsafe: true
handlers:
#same handlers as app.yaml

最后我的cron.yaml如下所示:

cron:
- description: update reports
  url: /update
  schedule: every day 12:00
  target: reporting

我需要该模块,因为该作业需要比普通实例提供更多的内存。但是,出于某种原因,当我查看应用程序的日志时,它会在默认模块上执行 cron 作业。为什么不接受目标参数?

事实证明,我错过了使用以下命令上传模块本身:

appcfg update app.yaml reporting.yaml

完成此操作后,目标参数起作用。

请检查 GAE 文档中的以下文本 - 版本而不是模块的目标元素。

如果已为作业设置了目标参数,则请求将发送到 指定的版本

如何将 cron 作业转发到您的目标模块,如 GAE 文档中的以下示例代码所示?

import urllib2
from google.appengine.api import modules
url = "http://%s/" % modules.get_hostname(module="reporting")
try:
  result = urllib2.urlopen(url)
  doSomethingWithResult(result)
except urllib2.URLError, e:
  handleError(e)

最新更新