Search code examples
python-2.7debuggingwebsockettornado

Debuging of 500 http response


I need to fix some issues on an application written in Tornado. It is REST canvas app which use socket to communicate with the server. Sometimes it generates 500 error when user tries to logout during some nodes' loading. I tried to replace 500 response with 402 type by using Try block in certain handler, but I am still getting 500 in the client. So I need to get exact line of Python code that generates error. Unfortunately I am not sure how to check those as all my browser is showing is 500 error, that's it.


Solution

  • If you start your application from the command line and then trigger the HTTP 500 error, you should see a traceback written to the console. Or at least it will appear in the log file.

    Or, update the code that creates the tornado.web.Application instance in your application's main file, and pass debug=True to the Application() constructor. That turns on several options including serve_traceback. Then you should see a full traceback in the error response, not just a "500".