Skip to content
Draft
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion requirements-testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ asttokens
responses
pysocks
socksio
httpcore[http2]
setuptools
Brotli
docker
5 changes: 4 additions & 1 deletion scripts/populate_tox/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,16 @@
"djangorestframework",
"pytest-django",
"Werkzeug",
"channels[daphne]",
],
">=2.0": ["channels[daphne]"],
">=2.2,<3.1": ["six"],
">=3.0": ["pytest-asyncio"],
"<3.3": [
"djangorestframework>=3.0,<4.0",
"Werkzeug<2.1.0",
],
"<3.1": ["pytest-django<4.0"],
"py3.6": ["dataclasses"],
"py3.14,py3.14t": ["coverage==7.11.0"],
},
},
Expand Down Expand Up @@ -162,6 +163,7 @@
"itsdangerous>=0.24,<2.0",
"jinja2<3.1.1",
],
"py3.6": ["dataclasses"],
},
},
"gql": {
Expand Down Expand Up @@ -512,6 +514,7 @@
"deps": {
"*": ["werkzeug"],
"<=5.0": ["werkzeug<1.0"],
"py3.6": ["dataclasses"],
},
},
"typer": {
Expand Down
5 changes: 4 additions & 1 deletion scripts/populate_tox/tox.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ deps =
-r requirements-testing.txt

# === Common ===
py3.6-common: dataclasses
py3.8-common: hypothesis
common: pytest-asyncio
common: httpcore[asyncio]
common: httpcore[asyncio,http2]
# See https://github.com/pytest-dev/pytest/issues/9621
# and https://github.com/pytest-dev/pytest-forked/issues/67
# for justification of the upper bound on pytest
Expand All @@ -90,13 +91,15 @@ deps =
{py3.14,py3.14t}-common: coverage==7.11.0

# === Gevent ===
py3.6-gevent: dataclasses
{py3.6,py3.7,py3.8,py3.9,py3.10,py3.11}-gevent: gevent>=22.10.0, <22.11.0
{py3.12}-gevent: gevent
# See https://github.com/pytest-dev/pytest/issues/9621
# and https://github.com/pytest-dev/pytest-forked/issues/67
# for justification of the upper bound on pytest
{py3.6,py3.7}-gevent: pytest<7.0.0
{py3.8,py3.9,py3.10,py3.11,py3.12}-gevent: pytest
gevent: httpcore[http2]
gevent: pytest-asyncio
gevent: setuptools<82
{py3.10,py3.11}-gevent: zope.event<5.0.0
Expand Down
43 changes: 20 additions & 23 deletions sentry_sdk/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import base64
import contextvars
import copy
import json
import linecache
Expand Down Expand Up @@ -84,28 +83,6 @@

_installed_modules = None

_is_sentry_internal_task = contextvars.ContextVar(
"is_sentry_internal_task", default=False
)

# These exceptions won't set the span status to error if they occur. Use
# register_control_flow_exception to add to this list
_control_flow_exception_classes: "set[type]" = set()


def is_internal_task() -> bool:
return _is_sentry_internal_task.get()


@contextmanager
def mark_sentry_task_internal() -> "Generator[None, None, None]":
"""Context manager to mark a task as Sentry internal."""
token = _is_sentry_internal_task.set(True)
try:
yield
finally:
_is_sentry_internal_task.reset(token)


BASE64_ALPHABET = re.compile(r"^[a-zA-Z0-9/+=]*$")

Expand Down Expand Up @@ -1468,6 +1445,26 @@ def _get_contextvars() -> "Tuple[bool, type]":
Please refer to https://docs.sentry.io/platforms/python/contextvars/ for more information.
"""

_is_sentry_internal_task = ContextVar("is_sentry_internal_task", default=False)

# These exceptions won't set the span status to error if they occur. Use
# register_control_flow_exception to add to this list
_control_flow_exception_classes: "set[type]" = set()


def is_internal_task() -> bool:
return _is_sentry_internal_task.get()


@contextmanager
def mark_sentry_task_internal() -> "Generator[None, None, None]":
"""Context manager to mark a task as Sentry internal."""
token = _is_sentry_internal_task.set(True)
try:
yield
finally:
_is_sentry_internal_task.reset(token)


def qualname_from_function(func: "Callable[..., Any]") -> "Optional[str]":
"""Return the qualified name of func. Works with regular function, lambda, partial and partialmethod."""
Expand Down
17 changes: 8 additions & 9 deletions tox.ini

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading