【发布时间】:2013-08-26 00:13:58
【问题描述】:
我遇到了一个看起来很常见的问题。但是,通常建议的解决方案似乎在这里不起作用。尝试运行 App Engine 时出现“无法使用 CGI 处理程序启用线程安全”。当然,文档很糟糕。我使用的是 webapp2,所以线程安全无关紧要。
我的文件结构应该如下: backend/api/get_json.py - 这为所有到达 /api/*.json 的 HTTP 请求提供服务。换句话说,后端/部分对最终用户是隐藏的。
我无法让 app.yaml 识别并正确加载位于 /backend/api/get_json.py 的 Python 文件
app.yaml 文件:
application: ebtest
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /api/.*\.json
script: backend/api/get_json.application
libraries:
- name: webapp2
version: "2.5.2"
后端/api/get_json.py
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello, World!')
application = webapp2.WSGIApplication([
('/api/get_users.json', MainPage),
], debug=True)
错误
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/yaml_listener.py", line 177, in _HandleEvents
raise yaml_errors.EventError(e, event_object)
google.appengine.api.yaml_errors.EventError: **threadsafe cannot be enabled with CGI handler: backend/api/get_json.application**
【问题讨论】:
-
线程安全不应该是真的而不是真的吗?我也认为您不需要在库中指定 webapp2 。至少这就是我的应用程序中的内容
-
我认为现在我查看文档应该是正确的;不幸的是,这并不能解决问题。我在离线和上面的sn-p中更新了代码。