From 238426917f24f3dde64c6117003bf876605fa646 Mon Sep 17 00:00:00 2001 From: Patrick Browne Date: Mon, 3 Oct 2016 21:52:20 +0200 Subject: [PATCH] feat(import_app): print original exception on AppImportError (#1334) * feat(import_app): print original exception on AppImportError --- gunicorn/util.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gunicorn/util.py b/gunicorn/util.py index a011fb8535..3bbb92c3ce 100644 --- a/gunicorn/util.py +++ b/gunicorn/util.py @@ -24,6 +24,7 @@ import errno import warnings import cgi +import logging from gunicorn.errors import AppImportError from gunicorn.six import text_type @@ -384,9 +385,12 @@ def import_app(module): mod = sys.modules[module] + is_debug = logging.root.level == logging.DEBUG try: app = eval(obj, mod.__dict__) except NameError: + if is_debug: + traceback.print_exception(*sys.exc_info()) raise AppImportError("Failed to find application: %r" % module) if app is None: @@ -565,4 +569,4 @@ def app(environ, start_response): ]) return [msg] - return app \ No newline at end of file + return app