Найти - Пользователи
Полная версия: Не могу отобразить трейсбек flask в GAE
Начало » Google App Engine » Не могу отобразить трейсбек flask в GAE
1
cpu
Собственно, сабж. Решил поиграться с flask`ом под GAE.
Простейшее приложение:
from flask import Flask
app = Flask(__name__)
app.use_debugger = app.debug =  True
@app.route('/', methods=['GET'])
def index():
    raise Exception('This is any exception text')
from google.appengine.ext.webapp.util import run_wsgi_app
run_wsgi_app(app)

выполняется такой командой:
python ~/google_appengine/dev_appserver.py ~/sample/
в консоли вижу трейсбек, а в http-выхлопе пусто:
Traceback (most recent call last):
  File "/home/cpu/google_appengine/google/appengine/runtime/wsgi.py", line 195, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/home/cpu/google_appengine/google/appengine/runtime/wsgi.py", line 239, in _LoadHandler
    handler = __import__(path[0])
  File "/home/cpu/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 719, in Decorate
    return func(self, *args, **kwargs)
  File "/home/cpu/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1923, in load_module
    return self.FindAndLoadModule(submodule, fullname, search_path)
  File "/home/cpu/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 719, in Decorate
    return func(self, *args, **kwargs)
  File "/home/cpu/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1787, in FindAndLoadModule
    description)
  File "/home/cpu/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 719, in Decorate
    return func(self, *args, **kwargs)
  File "/home/cpu/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1730, in LoadModuleRestricted
    description)
  File "/home/cpu/sample/main.py", line 32, in <module>
    run_wsgi_app(app)
  File "/home/cpu/google_appengine/google/appengine/ext/webapp/util.py", line 98, in run_wsgi_app
    run_bare_wsgi_app(add_wsgi_middleware(application))
  File "/home/cpu/google_appengine/google/appengine/ext/webapp/util.py", line 116, in run_bare_wsgi_app
    result = application(env, _start_response)
  File "/home/cpu/sample/flask/app.py", line 1518, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/cpu/sample/flask/app.py", line 1506, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/home/cpu/sample/flask/app.py", line 1504, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/cpu/sample/flask/app.py", line 1264, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/cpu/sample/flask/app.py", line 1262, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/cpu/sample/flask/app.py", line 1248, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/cpu/sample/main.py", line 28, in index
    raise Exception('This is any exception text')
Exception: This is any exception text
cpu
разобрался:
from flask import Flask
app = Flask(__name__)
app.use_debugger = app.debug =  True
@app.route('/', methods=['GET'])
def index():
    raise Exception('This is any exception text')
from google.appengine.ext.webapp.util import run_wsgi_app
from werkzeug import DebuggedApplication        # << 
app = DebuggedApplication(app, evalex=True)    # <<
run_wsgi_app(app)
И, наверно, DebuggedApplication лучше использовать только в дев-окружении, а в продакте трейсбеки слать разрабу на мыло
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB