diff options
author | David Cramer <dcramer@gmail.com> | 2017-06-30 11:50:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-30 11:50:40 -0700 |
commit | d8d3c834b7d3792bdef93a55e876ace1630579c6 (patch) | |
tree | f3bffe901b284ffe1e2c2b2cd284a6e03a5fecf4 | |
parent | 18698aa643f83cc9e134e5ef1500f8e75b43bf5d (diff) | |
parent | 0b4609aa4e6a4a749dc4bd7c019c76d80a5db899 (diff) | |
download | raven-d8d3c834b7d3792bdef93a55e876ace1630579c6.tar.gz |
Merge pull request #1033 from getsentry/fix/recursion
Fix import locking to avoid recursion (fixes GH-1032)
-rw-r--r-- | raven/contrib/django/models.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/raven/contrib/django/models.py b/raven/contrib/django/models.py index 4772e10..08caa67 100644 --- a/raven/contrib/django/models.py +++ b/raven/contrib/django/models.py @@ -245,15 +245,19 @@ def initialize(): if _initialized: return - register_serializers() - install_middleware() - - # XXX(dcramer): maybe this setting should disable ALL of this? - if not getattr(settings, 'DISABLE_SENTRY_INSTRUMENTATION', False): - handler = SentryDjangoHandler() - handler.install() - - # instantiate client so hooks get registered - get_client() # NOQA - + # mark this as initialized immediatley to avoid recursive import issues _initialized = True + + try: + register_serializers() + install_middleware() + + # XXX(dcramer): maybe this setting should disable ALL of this? + if not getattr(settings, 'DISABLE_SENTRY_INSTRUMENTATION', False): + handler = SentryDjangoHandler() + handler.install() + + # instantiate client so hooks get registered + get_client() # NOQA + except Exception: + _initialized = False |