Skip to content

Commit

Permalink
Do not raise error when channels is not installed (#3203)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpirker authored Jun 26, 2024
1 parent 7c1685e commit 9506913
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions sentry_sdk/integrations/django/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,10 @@ def sentry_patched_drf_initial(self, request, *args, **kwargs):
def _patch_channels():
# type: () -> None
try:
# Django < 3.0
from channels.http import AsgiHandler # type: ignore
except ImportError:
try:
# DJango 3.0+
from django.core.handlers.asgi import ASGIHandler as AsgiHandler
except ImportError:
return
return

if not HAS_REAL_CONTEXTVARS:
# We better have contextvars or we're going to leak state between
# requests.
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/django/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ async def sentry_patched_get_response_async(self, request):

def patch_channels_asgi_handler_impl(cls):
# type: (Any) -> None

import channels # type: ignore

from sentry_sdk.integrations.django import DjangoIntegration

if channels.__version__ < "3.0.0":
Expand Down

0 comments on commit 9506913

Please sign in to comment.