简体   繁体   English

Python:WSGI崩溃而没有错误

[英]Python: WSGI crashing with no error

I'm currently developing a web service in WSGI, but the script crashes on the line where I am executing my query. 我目前正在WSGI中开发Web服务,但是脚本在执行查询的那一行崩溃。 I'm using the exact same code as other working web services, and even simplified my query for testing purposes, but to no avail. 我使用的代码与其他可用的Web服务完全相同,甚至简化了查询以进行测试,但无济于事。 The real problem is that while I can manually print stuff to the error_log specified in my VirtualHost, there is no log for the error that occurs when the script crashes. 真正的问题是,尽管我可以手动将内容打印到VirtualHost中指定的error_log中,但没有脚本崩溃时发生的错误的日志。 All I know now is that the print before the line is written to the log, but the print after isn't. 我现在所知道的是,将行之前的打印内容写入日志,但不打印之后的内容。 How can I print the error to the log and get to the root of my problem? 如何将错误打印到日志并找到问题的根源?

The code (simplified a bit): 代码(简化一点):

webservice.wsgi: webservice.wsgi:

def application(environ, start_response):
  ENV = environ.get('APPLICATION_ENV', 'DEV')
  connector = ConnectorObj(confParams['dbname'], confParams['host'], confParams['port'], confParams['user'], confParams['password'])
  method = environ.get('REQUEST_METHOD', '')
  if (method == 'POST'):
    content_body = json.loads(request_body)
    han = HandlerObj(connector)
    res = han.getBld()
    start_response('200 OK', [('content-type', 'application/json; charset=utf-8'), ('Access-Control-Allow-Origin', '*')])
    return(res)

getBld: getBld:

def getBld(self):
  print "execute query"
  self.cur.execute("""
    SELECT * FROM adr.bld
  """)
  print "after executing query"

After doing the post call, I can see that "execute query" is being printed to the error_log, but then it just crashes and doesn't get to "after executing query". 在执行post调用之后,我可以看到“执行查询”被打印到error_log上,但是它只是崩溃了,并没有进入“执行查询后”。

Again, I'm not asking what is wrong with my actual code (I would have to provide much more in order to make sense of it), but simply how I can get an error trace somehow so I can start to debug it myself.. 再次,我不是在问实际代码有什么问题(我必须提供更多信息才能理解它),而只是简单地知道如何以某种方式获取错误跟踪,以便自己开始调试它。 。

It depends on the database you use. 这取决于您使用的数据库。 If it is some open source I would recommend taking the source codes and compiling it with enabled debug mode which will result DB to create log file for itself which can point to the error. 如果它是开放源代码,我建议采用源代码并使用启用的调试模式进行编译,这将导致DB为其自身创建日志文件,该日志文件可能指向错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM