summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Ronacher <armin.ronacher@active-4.com>2016-07-19 19:45:29 +0500
committerArmin Ronacher <armin.ronacher@active-4.com>2016-07-19 19:45:29 +0500
commit8a4c0a889dd2dd8eb50a822765a1748352d8ea58 (patch)
tree915f2eb752a2efc338b957d0cf8798ffc08ba5e7
parent02aa7bee9addd1aaf2016af181c27a6ef9f37d01 (diff)
downloadraven-8a4c0a889dd2dd8eb50a822765a1748352d8ea58.tar.gz
Do not log exceptions from the django cli client twice. This fixes #802
-rw-r--r--raven/base.py8
-rw-r--r--raven/contrib/django/management/__init__.py12
2 files changed, 17 insertions, 3 deletions
diff --git a/raven/base.py b/raven/base.py
index bae7584..d036379 100644
--- a/raven/base.py
+++ b/raven/base.py
@@ -59,6 +59,13 @@ SDK_VALUE = {
Raven = None
+def get_excepthook_client():
+ hook = sys.excepthook
+ client = getattr(hook, 'raven_client', None)
+ if client is not None:
+ return client
+
+
class ModuleProxyCache(dict):
def __missing__(self, key):
module, class_name = key.rsplit('.', 1)
@@ -237,6 +244,7 @@ class Client(object):
def handle_exception(*exc_info):
self.captureException(exc_info=exc_info)
__excepthook__(*exc_info)
+ handle_exception.raven_client = self
sys.excepthook = handle_exception
def install_logging_hook(self):
diff --git a/raven/contrib/django/management/__init__.py b/raven/contrib/django/management/__init__.py
index 07ed7d3..6e7a548 100644
--- a/raven/contrib/django/management/__init__.py
+++ b/raven/contrib/django/management/__init__.py
@@ -18,6 +18,8 @@ def patch_cli_runner():
Patches ``cls.execute``, returning a boolean describing if the
attempt was successful.
"""
+ from raven.baes import get_excepthook_client
+
try:
from django.core.management.base import BaseCommand
except ImportError:
@@ -42,9 +44,13 @@ def patch_cli_runner():
except Exception:
from raven.contrib.django.models import client
- client.captureException(extra={
- 'argv': sys.argv
- })
+ # Since this is an unhandled exception that falls through
+ # we only want to log it if the given client is not the
+ # one that handles the global exceptions.
+ if get_excepthook_client() is not client:
+ client.captureException(extra={
+ 'argv': sys.argv
+ })
raise
new_execute.__raven_patched = True