我第二次想知道使用哪个版本的 Python Google Appengine Python 2.7 运行时。
这是自 2.6 以来绝对有效的 Python,我希望 query_string 之后是“测试”:
query_string = "(test)"
query_string = query_string.translate(None, "()")
但在 Google Appengine 上,它会导致 TypeError translate() takes exactly one argument (2 given)
上周,我们遇到了另一种奇怪的行为,一个函数 a 调用了另一个函数 b,这可能会引发 ValueError。我可以在函数 b 中捕获异常,但不能在 a 中捕获异常,因为异常的传播,后端刚刚崩溃。 不过,几个小时后,这个错误(?)被修复了。
编辑:我正在使用 Python 2.7 运行时,sys.version
返回 2.7.3(默认,2012 年 10 月 15 日,11:27:13)
应用程序.yaml:
application: test
version: 1
runtime: python27
api_version: 1
threadsafe: no
最佳答案
根据您的更新进行编辑:
这可能是也可能不是问题的根本原因,但您的 app.yaml
不正确。 threadsafe
的允许值为 true
或 false
。链接到文档的相应部分:https://developers.google.com/appengine/docs/python/config/appconfig
原答案:
如果您没有在 app.yaml
中指定 GAE 应为您的应用程序使用 Python 2.7 运行时,则可能发生这种情况的唯一方法。下面是an example from the excellent documentation :
application: helloworld
version: 1
# vvvvvvvv
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: helloworld.app
如果您没有为runtime
指定python27
,GAE 将使用Python 2.5
关于python - Appengine 中使用什么版本/风格的 Python?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15100125/