question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Runserver_plus exceptions stacktrace is polluted

See original GitHub issue

Hi there,

When an uncaught exception occurs in my apps using runserver_plus, the stacktrace is going through a significant amount of redundant code, and I can’t figure out why. 10 calls are made to six.reraise(exc_type, exc_value, tb). I think it should probably be improved for clarity.

Using Django 1.11 / Python 2.7 / Django Extensions last table (2.0.7).

127.0.0.1 - - [30/Apr/2018 14:55:01] "GET /crash/ HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 63, in __call__
    return self.application(environ, start_response)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 157, in __call__
    response = self.get_response(request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 124, in get_response
    response = self._middleware_chain(request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 43, in inner
    response = response_for_exception(request, exc)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 93, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 139, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
    six.reraise(exc_type, exc_value, tb)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/utils/deprecation.py", line 140, in __call__
    response = self.get_response(request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 43, in inner
    response = response_for_exception(request, exc)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 93, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 139, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
    six.reraise(exc_type, exc_value, tb)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/utils/deprecation.py", line 140, in __call__
    response = self.get_response(request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 43, in inner
    response = response_for_exception(request, exc)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 93, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 139, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
    six.reraise(exc_type, exc_value, tb)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/utils/deprecation.py", line 140, in __call__
    response = self.get_response(request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 43, in inner
    response = response_for_exception(request, exc)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 93, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 139, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
    six.reraise(exc_type, exc_value, tb)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/utils/deprecation.py", line 140, in __call__
    response = self.get_response(request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 43, in inner
    response = response_for_exception(request, exc)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 93, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 139, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
    six.reraise(exc_type, exc_value, tb)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/utils/deprecation.py", line 140, in __call__
    response = self.get_response(request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 43, in inner
    response = response_for_exception(request, exc)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 93, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 139, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
    six.reraise(exc_type, exc_value, tb)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/utils/deprecation.py", line 140, in __call__
    response = self.get_response(request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 43, in inner
    response = response_for_exception(request, exc)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 93, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 139, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
    six.reraise(exc_type, exc_value, tb)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/utils/deprecation.py", line 140, in __call__
    response = self.get_response(request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 43, in inner
    response = response_for_exception(request, exc)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 93, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 139, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
    six.reraise(exc_type, exc_value, tb)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Users/antwan/Projects/myproject/apps/core/middleware.py", line 14, in __call__
    return self.get_response(request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 43, in inner
    response = response_for_exception(request, exc)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 93, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 139, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
    six.reraise(exc_type, exc_value, tb)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/utils/deprecation.py", line 140, in __call__
    response = self.get_response(request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 43, in inner
    response = response_for_exception(request, exc)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 93, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 139, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
    six.reraise(exc_type, exc_value, tb)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/antwan/Projects/myproject/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/antwan/Projects/myproject/apps/core/views.py", line 506, in crash_view
    raise Exception('A test exception occured!')

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
jhselvikcommented, Jul 26, 2018

I took another look today and changed my mind, null_technical_500_response will need to be modified to clean up the stacktrace. Django calls django_extensions’s null_technical_500_response for each Middleware Mixin object in a stack (because it is overridden in runserver_plus.py). By the time an uncaught exception occurs in the django app there are typically 8-10 of these Mixins in the stack, hence all the six reraise calls on top of the original exception.

I don’t think this is related to python 3’s exception chaining as mentioned here. I think null_technical_500_response needs to be modified to return django_extensions’s version of a response to be displayed, instead of raising an exception. Not sure how to do this yet, but should be able to figure it out next time I can look in a few days.

3reactions
mbeacomcommented, Jul 23, 2018

@antwan @trbs Would you be open to me creating a bounty for this issue on Gitcoin ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Print a stack trace to stdout on errors in Django while using ...
Specifically you get a stacktrace when running ./manage.py runserver by adding the following to ... getLogger('django.request') logger.exception(unicode(e)).
Read more >
RunServerPlus — django-extensions 3.2.1 documentation
synopsis: RunServerPlus-typical runserver with Werkzeug debugger baked in ... the Werkzeug traceback page will be shown when an exception occurs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found