-
Couldn't load subscription status.
- Fork 569
fix: Data leak in ThreadingIntegration between threads #4281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 32 commits
7d14008
9c35e83
664f0e0
0d9a221
0100bdb
bd44959
0e92608
fd69f64
e4d94a5
c7af4b9
678f515
eef7ff6
518dc04
24ea433
0d5b3fb
d3585a3
5bcba35
4c2f7d9
890640f
957d7bb
07d44c9
2a2cde1
8cd789b
6982479
3b85ef4
e783af9
160e430
8cd1584
9aad099
0da1c2e
096579e
33d9f3d
815e930
5d306ee
8aa5edf
ca8aa30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import sys | ||
| import warnings | ||
| from functools import wraps | ||
| from threading import Thread, current_thread | ||
|
|
||
|
|
@@ -57,8 +58,36 @@ def sentry_start(self, *a, **kw): | |
| return old_start(self, *a, **kw) | ||
|
|
||
| if integration.propagate_scope: | ||
| isolation_scope = sentry_sdk.get_isolation_scope() | ||
| current_scope = sentry_sdk.get_current_scope() | ||
| try: | ||
| from django import VERSION as django_version # noqa: N811 | ||
| import channels # type: ignore[import-not-found] | ||
|
|
||
| channels_version = channels.__version__ | ||
| except ImportError: | ||
| django_version = None | ||
| channels_version = None | ||
|
|
||
| if ( | ||
| sys.version_info <= (3, 8) | ||
| and channels_version is not None | ||
| and channels_version < "4.0.0" | ||
| and django_version is not None | ||
| and django_version >= (3, 0) | ||
| and django_version < (4, 0) | ||
| ): | ||
| warnings.warn( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is happening in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the problem with the unawaited future is only happening if old python, django and channels are used in combination. on a vanilla python project on old python versions the threading works fine. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, my point was more that someone might have Django/channels installed in their venv but uses threads in an unrelated script that has nothing to do with their Django app and they would get this warning too. But as said, I don't see a way around this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. now I get it. yes that is true. but as you said, the warning is only emitted once, so I think it is ok. |
||
| "There is a known issue with Django channels 2.x and 3.x when using Python 3.8 or older. " | ||
| "(Async support is emulated using threads and some Sentry data may be leaked between those threads.) " | ||
| "Please either upgrade to Django channels 4.0+, use Django's async features " | ||
| "available in Django 3.1+ instead of Django channels, or upgrade to Python 3.9+.", | ||
| stacklevel=2, | ||
| ) | ||
| isolation_scope = sentry_sdk.get_isolation_scope() | ||
| current_scope = sentry_sdk.get_current_scope() | ||
|
|
||
| else: | ||
| isolation_scope = sentry_sdk.get_isolation_scope().fork() | ||
| current_scope = sentry_sdk.get_current_scope().fork() | ||
| else: | ||
| isolation_scope = None | ||
| current_scope = None | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.