Skip to content

Commit 9506913

Browse files
authored
Do not raise error when channels is not installed (#3203)
1 parent 7c1685e commit 9506913

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

sentry_sdk/integrations/django/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,10 @@ def sentry_patched_drf_initial(self, request, *args, **kwargs):
325325
def _patch_channels():
326326
# type: () -> None
327327
try:
328-
# Django < 3.0
329328
from channels.http import AsgiHandler # type: ignore
330329
except ImportError:
331-
try:
332-
# DJango 3.0+
333-
from django.core.handlers.asgi import ASGIHandler as AsgiHandler
334-
except ImportError:
335-
return
330+
return
331+
336332
if not HAS_REAL_CONTEXTVARS:
337333
# We better have contextvars or we're going to leak state between
338334
# requests.

sentry_sdk/integrations/django/asgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ async def sentry_patched_get_response_async(self, request):
134134

135135
def patch_channels_asgi_handler_impl(cls):
136136
# type: (Any) -> None
137-
138137
import channels # type: ignore
138+
139139
from sentry_sdk.integrations.django import DjangoIntegration
140140

141141
if channels.__version__ < "3.0.0":

0 commit comments

Comments
 (0)