Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions sentry_sdk/integrations/threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,14 @@ def setup_once() -> None:

try:
from django import VERSION as django_version # noqa: N811
except ImportError:
django_version = None

try:
import channels # type: ignore[import-untyped]

channels_version = channels.__version__
except ImportError:
django_version = None
except (ImportError, AttributeError):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this implies that if there is an AttributeError because of channels line, django_version will be set to None and that is not ideal... perhaps we should split this try/except in 2 parts, 1 for django and another for channels?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this implies that if there is an AttributeError because of channels line, django_version will be set to None and that is not ideal... perhaps we should split this try/except in 2 parts, 1 for django and another for channels?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's ok, django_version and channels_version both are only used for warning about a very specific Django/channels/sentry-sdk incompatibility that only appears in specific versions.

But you raise a good point in that it's not clear what the variable is used for. It might happen that someone extends the logic at some point using django_version for some other purpose, not realizing it's not always populated correctly. So it's worth making this nicer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

channels_version = None

is_async_emulated_with_threads = (
Expand Down
Loading