[Django]-How do I make Django signal handlers not fail silently when an exception is encountered in the signal handler?


When using manage.py shell I get an uncaught exception when manually creating a FollowTable from your example. However, uncaught exceptions during a request don’t show up in the terminal (other than showing that 500 was returned), instead they are shown in the browser. If you’re using JavaScript to make requests you might want to look in firebug/chrome developer tools to see if it’s returning a traceback.

Looks like someone else has answered how to get tracebacks to show in the console:

Seemed to work for me. I did the following:

  1. Added the ExceptionLoggingMiddleware class to my_app/__init__.py
  2. Added 'my_app.ExceptionLoggingMiddleware' to MIDDLEWARE_CLASSES in settings.py
  3. Restarted the development server


Yes, errors should never fail silently

Yes, I think like you: errors should never fail silently

Built in signals don’t fail silently

Django’s built in signals don’t fail silently because they use send()

Only send_robust() ignores exceptions

Docs from send_robust()

send_robust() catches all errors derived from Python’s Exception class, and ensures all receivers are notified of the signal. If an error occurs, the error instance is returned in the tuple pair for the receiver that raised the error.


Since django doesn’t use send_robust() please investigate where it gets called. I guess it is in your source code, or in the code of a third party app.

Leave a comment