﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
1023	mail_admins called even on SystemExit	hugo	Adrian Holovaty	"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.
"	defect	closed	Core (Other)		normal	fixed			Unreviewed	0	0	0	0	0	0
