Google app engine AppEngine标准Python 3.7不提供500响应的错误消息

Google app engine AppEngine标准Python 3.7不提供500响应的错误消息,google-app-engine,google-app-engine-python,Google App Engine,Google App Engine Python,我正在使用python3.7标准环境创建AppEngine应用程序。该应用程序在本地正常工作,但上载时会在浏览器中抛出500错误,显示: "Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application." p

我正在使用python3.7标准环境创建AppEngine应用程序。该应用程序在本地正常工作,但上载时会在浏览器中抛出500错误,显示:

"Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application."
python3.7没有启用调试(它告诉我在查看调试器时会这样)。日志条目中没有针对500响应的错误消息提示

如何继续调试并了解应用程序发生了什么

我应该注意到,我正在尝试使用Selenium webdriver来运行headless chrome,但我不能100%确定它是否与此环境兼容,我只是想尝试一下

根据建议添加日志

https://console.cloud.google.com/logs/viewer?project={project-id}&resource=gae_app%2Fmodule_id%2Fdefault%2Fversion_id%2F20180916t193009&minLogLevel=0&expandAll=false&timestamp=2018-09-17T18%3A18%3A21.295000000Z&customFacets&limitCustomFacetWidth=true&interval=PT1H&scrollTimestamp=2018-09-17T18%3A16%3A59.235127000Z&advancedFilter=resource.type%3D%22gae_app%22%0Aresource.labels.zone%3D%22us-west2-3%22%0Aresource.labels.project_id%3D%22{project-id}%22%0Aresource.labels.version_id%3D%2220180916t193009%22%0Aresource.labels.module_id%3D%22default%22%0Atimestamp%3D%222018-09-17T18%3A16%3A57.883459000Z%22%0AinsertId%3D%225b9fef9e0005ebc57890705d%22&dateRangeUnbound=both

{
 httpRequest: {
  status:  500   
 }
 insertId:  "5b9fef9e0005ebc57890705d"  
 labels: {
  clone_id:  "00c61b117c38b726d0ba73ce89f222fe10b9b189fae907de84b949ab7a3b88ec4bdc4484"   
 }
 logName:  "projects/{project-id}/logs/appengine.googleapis.com%2Frequest_log"  
 operation: {
  first:  true   
  id:  "5b9fef9900ff0d7b03fbff00a7c100016d7e7370656e642d6d6f6e69746f720001323031383039313674313933303039000100"   
  last:  true   
  producer:  "appengine.googleapis.com/request_id"   
 }
 protoPayload: {
  @type:  "type.googleapis.com/google.appengine.logging.v1.RequestLog"   
  appEngineRelease:  "1.9.64"   
  appId:  "m~{project-id}"   
  cost:  4.7272999999999996e-8   
  endTime:  "2018-09-17T18:17:02.387819Z"   
  finished:  true   
  first:  true   
  host:  "{project-id}.appspot.com"   
  httpVersion:  "HTTP/1.1"   
  instanceId:  "00c61b117c38b726d0ba73ce89f222fe10b9b189fae907de84b949ab7a3b88ec4bdc4484"   
  instanceIndex:  -1   
  ip:  "80.195.185.178"   
  latency:  "4.504360s"   
  line: [
   0: {
    logMessage:  "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."     
    severity:  "INFO"     
    time:  "2018-09-17T18:17:02.387649Z"     
   }
  ]
  megaCycles:  "6127"   
  method:  "GET"   
  requestId:  "5b9fef9900ff0d7b03fbff00a7c100016d7e7370656e642d6d6f6e69746f720001323031383039313674313933303039000100"   
  resource:  "/"   
  responseSize:  "423"   
  startTime:  "2018-09-17T18:16:57.883459Z"   
  status:  500   
  traceId:  "37cee4aaaa0b14fbaa6d57b7842527dc"   
  traceSampled:  true   
  urlMapEntry:  "auto"   
  userAgent:  "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"   
  versionId:  "20180916t193009"   
  wasLoadingRequest:  true   
 }
 receiveTimestamp:  "2018-09-17T18:17:02.563417716Z"  
 resource: {
  labels: {
   module_id:  "default"    
   project_id:  "{project-id}"    
   version_id:  "20180916t193009"    
   zone:  "us-west2-3"    
  }
  type:  "gae_app"   
 }
 severity:  "INFO"  
 timestamp:  "2018-09-17T18:16:57.883459Z"  
 trace:  "projects/{project-id}/traces/37cee4aaaa0b14fbaa6d57b7842527dc"  
 traceSampled:  true  
}

为了进一步调试,我插入了一个try/catch块,如下所示:

尝试: {应用程序代码} 例外情况除外,如e: 返回str(e)


当应用程序失败时,这会在浏览器中显示顶级错误消息。

您可以查看并检查此请求发生的时间范围。如果您可以在此处发布相关日志实体,您将有更好的机会获得解决方案。@Yurci感谢您的建议。我听从了你的建议。正如你提到的,你的日志并没有暗示这个问题。在这一点上,我建议实现您的自定义,它也将输出到。最好的办法是检测导致此错误的代码的哪一部分。谢谢@Yurci-这启发了我插入一个简单的try/catch块,成功了。遗憾的是,在这种环境下,似乎还不可能使用无头铬。@Yurci再次感谢您!