mail_admins called even on SystemExit
|Reported by:||hugo||Owned by:||Adrian Holovaty|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
If DEBUG=False, Django mails about exceptions to the admins. That's generally great. But it even mails them on SystemExit exceptions - which are only triggered if the programmer deliberately called sys.exit with some exit code. I think SystemExit should be ignored for mailing, as the coder would surely have plugged his own mailing if that would have been needed. Especially if the exit code is 0 ...
Something along the lines:
Index: core/handlers/base.py =================================================================== --- core/handlers/base.py (revision 1565) +++ core/handlers/base.py (working copy) @@ -104,6 +104,8 @@ return self.get_friendly_error_response(request, resolver) except exceptions.PermissionDenied: return httpwrappers.HttpResponseForbidden('<h1>Permission denied</h1>') + except SystemExit: + pass except: # Handle everything else, including SuspiciousOperation, etc. if DEBUG: return self.get_technical_error_response(request)
Why this arises in my system: I have a job control app running that triggers background processes - and since they are triggered in the view functions, they have the full stack of the base handler active. The background process just ends with sys.exit(0) if everything is ok, but due to the SystemExit messaging I get error messages in my mailbox.