Skip to content

Commit 6982479

Browse files
committed
Warning
1 parent 8cd789b commit 6982479

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

scripts/populate_tox/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"Werkzeug<2.1.0",
4646
],
4747
"<3.1": ["pytest-django<4.0"],
48-
">=2.0,<3.0": ["channels[daphne]"],
48+
">=2.0": ["channels[daphne]"],
4949
},
5050
},
5151
"dramatiq": {

sentry_sdk/integrations/threading.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
import warnings
23
from functools import wraps
34
from threading import Thread, current_thread
45

@@ -57,8 +58,36 @@ def sentry_start(self, *a, **kw):
5758
return old_start(self, *a, **kw)
5859

5960
if integration.propagate_scope:
60-
isolation_scope = sentry_sdk.get_isolation_scope().fork()
61-
current_scope = sentry_sdk.get_current_scope().fork()
61+
django_version = None
62+
channels_version = None
63+
try:
64+
from django import VERSION as django_version # noqa: N811
65+
import channels
66+
67+
channels_version = channels.__version__
68+
except ImportError:
69+
pass
70+
71+
if (
72+
sys.version_info <= (3, 8)
73+
and channels_version is not None
74+
and channels_version < "4.0.0"
75+
and django_version is not None
76+
and django_version >= (3, 0)
77+
and django_version < (4, 0)
78+
):
79+
warnings.warn(
80+
"Sentry is not supported with Django channels 2.x and 3.x. when using Python 3.8 or older. "
81+
"Please either upgrade to Django channels 4.x or later, or upgrade to Python 3.9 or later.",
82+
DeprecationWarning,
83+
stacklevel=2,
84+
)
85+
isolation_scope = sentry_sdk.get_isolation_scope()
86+
current_scope = sentry_sdk.get_current_scope()
87+
88+
else:
89+
isolation_scope = sentry_sdk.get_isolation_scope().fork()
90+
current_scope = sentry_sdk.get_current_scope().fork()
6291
else:
6392
isolation_scope = None
6493
current_scope = None

tox.ini

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# The file (and all resulting CI YAMLs) then need to be regenerated via
1111
# "scripts/generate-test-files.sh".
1212
#
13-
# Last generated: 2025-04-14T14:02:53.533465+00:00
13+
# Last generated: 2025-04-14T14:46:40.523627+00:00
1414

1515
[tox]
1616
requires =
@@ -642,6 +642,10 @@ deps =
642642
django-v1.11.29: pytest-django<4.0
643643
django-v2.2.28: pytest-django<4.0
644644
django-v2.2.28: channels[daphne]
645+
django-v3.2.25: channels[daphne]
646+
django-v4.2.20: channels[daphne]
647+
django-v5.0.9: channels[daphne]
648+
django-v5.2: channels[daphne]
645649

646650
flask-v1.1.4: flask==1.1.4
647651
flask-v2.3.3: flask==2.3.3

0 commit comments

Comments
 (0)