summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Robenolt <matt@ydekproductions.com>2015-11-12 17:20:16 -0800
committerMatt Robenolt <matt@ydekproductions.com>2015-11-12 17:20:16 -0800
commit3eddaa4dffaad3861282568f02bc8ad966be2fd8 (patch)
tree4c317d5b494df5f8b681173fb97756fc387ca208
parent276266822a8dd39a5a0746ec8ee69cdfe42bdb6c (diff)
downloadraven-3eddaa4dffaad3861282568f02bc8ad966be2fd8.tar.gz
Log SystemExit in wsgi middleware when code != 0
SystemExit does not subclass Exception, so we don't catch this. SystemExit manifests itself (at least) from gunicorn when gunicorn attempts to gracefully shut down a worker process. See GH-675 for more background. Fixes: GH-675
-rw-r--r--raven/middleware.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/raven/middleware.py b/raven/middleware.py
index 588bd6f..ca0dc21 100644
--- a/raven/middleware.py
+++ b/raven/middleware.py
@@ -36,6 +36,10 @@ class Sentry(object):
except Exception:
self.handle_exception(environ)
raise
+ except SystemExit as e:
+ if e.code != 0:
+ self.handle_exception(environ)
+ raise
try:
for event in iterable:
@@ -43,6 +47,10 @@ class Sentry(object):
except Exception:
self.handle_exception(environ)
raise
+ except SystemExit as e:
+ if e.code != 0:
+ self.handle_exception(environ)
+ raise
finally:
# wsgi spec requires iterable to call close if it exists
# see http://blog.dscpl.com.au/2012/10/obligations-for-calling-close-on.html
@@ -51,6 +59,10 @@ class Sentry(object):
iterable.close()
except Exception:
self.handle_exception(environ)
+ except SystemExit as e:
+ if e.code != 0:
+ self.handle_exception(environ)
+ raise
self.client.context.clear()
def get_http_context(self, environ):