How to migrate my app.yaml to 2.7?

2019-04-05 12:01发布

I'm migrating my gae app to python 2.7. This is my new 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

But I get this error message:

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

Can you tell me how to resolve the error?

2条回答
我只想做你的唯一
2楼-- · 2019-04-05 12:40

Checking the source code, it looks that you need to define your handlers' path without any slash:

   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)

Move application.py to the root of your project and modify the handler's path accordingly.

查看更多
Ridiculous、
3楼-- · 2019-04-05 12:49

Change:

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

To:

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

You may also need to add an __init__.py to the 'mapreduce' folder if one doesn't exist there already. That will make the python interpret the folder as a module.

查看更多
登录 后发表回答