如何将我的app.yaml迁移到2.7?

Nik*_*ntz 10 python google-app-engine yaml python-2.7

我正在将我的gae应用程序迁移到python 2.7.这是我的新app.yaml:

application: webfaze
version: main
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /mapreduce(/.*)?
  script: mapreduce/main.application

- url: /(.*\.(html|css|js|gif|jpg|png|ico|swf))
  static_files: static/\1
  upload: static/.*
  expiration: "1d"

- url: .*
  script: main.application

- url: /task/.*
  script: main.application
  login: admin
Run Code Online (Sandbox Code Playgroud)

但我收到此错误消息:

Error parsing yaml file:
Invalid object:
threadsafe cannot be enabled with CGI handler: mapreduce/main.application
  in "webfaze/app.yaml", line 22, column 1
Run Code Online (Sandbox Code Playgroud)

你能告诉我如何解决这个错误吗?

sys*_*out 7

检查源代码,看起来您需要定义处理程序的路径而不带任何斜杠:

   if (handler.script and (handler.script.endswith('.py') or 
       '/' in handler.script)):
       raise appinfo_errors.ThreadsafeWithCgiHandler(
                    'threadsafe cannot be enabled with CGI handler: %s' %
                    handler.script)
Run Code Online (Sandbox Code Playgroud)

移动application.py到项目的根目录并相应地修改处理程序的路径.

  • 或者将其命名为`mapreduce.main.application`. (7认同)
  • 在互联网上搜索后,我仍然无法命名`mapreduce.main.application`,我发现脚本:`google.appengine.ext.mapreduce.main.APP`来自:https://groups.google.com/forum/ ?fromgroups#!话题/谷歌的AppEngine/ZzW4hhqc7hI (2认同)

Eva*_*ice 7

更改:

- url: /mapreduce(/.*)?
  script: mapreduce/main.application
Run Code Online (Sandbox Code Playgroud)

至:

- url: /mapreduce(/.*)?
  script: mapreduce.main.application
Run Code Online (Sandbox Code Playgroud)

您可能还需要在'mapreduce'文件夹中添加__init__ .py(如果已经存在的话).这将使python将文件夹解释为模块.