Google App Engine: module has no attribute app ... but attribute app is there (called by /_ah/start)

StackOverflow https://stackoverflow.com/questions/21654459

parser.yaml

application: xyz
module: parser
version: 'v1'
runtime: python27
api_version: '1'
threadsafe: yes

instance_class: B2
basic_scaling:
  max_instances: 1
  idle_timeout: 10m

handlers:
- url: /.*
  script: parser.app

libraries:
- name: webapp2
  version: "2.5.2"

parser.py

import webapp2
class ParseHandler(webapp2.RequestHandler):
    def get(self):
        self.response.out.write("ok")

app = webapp2.WSGIApplication([
    ('/init', ParseHandler)
], debug=True)

Google App Engines requests to /_ah/start return an error (code 500):

"GET /_ah/start HTTP/1.1" 500 0 - - "0.v1.parser.xyz.appspot.com" ms=332 cpu_ms=27 loading_request=1 exit_code=111 instance=0 app_engine_release=1.8.9 

Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 239, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 301, in _LoadHandler
    raise err
ImportError: <module 'parser' (built-in)> has no attribute app

This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.

Process terminated because it failed to respond to the start request with an HTTP status code of 200-299 or 404.

But parser.py has the required app attribute. What is the problem?

I tried adding a dedicated route for /_ah/start and attached a handler to it in parser.py, but this does not solve the ImportError.

有帮助吗?

解决方案

The app engine appears to find a built-in parser module; a C library.

Try renaming your module from parser.py to something else.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top