Skip to content
Open
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
12 changes: 9 additions & 3 deletions sentry_sdk/integrations/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""

import sys
import asyncio
import inspect
from copy import deepcopy
from functools import partial
Expand Down Expand Up @@ -69,6 +68,13 @@
TRANSACTION_STYLE_VALUES = ("endpoint", "url")


# Vendored: https://github.com/Kludex/uvicorn/blob/b224045f5900b7f766743bcb16ba9fc3adea2606/uvicorn/_compat.py#L10-L13
if sys.version_info >= (3, 14):
from inspect import iscoroutinefunction
else:
from asyncio import iscoroutinefunction


def _capture_exception(exc: "Any", mechanism_type: str = "asgi") -> None:
event, hint = event_from_exception(
exc,
Expand All @@ -87,10 +93,10 @@ def _looks_like_asgi3(app: "Any") -> bool:
if inspect.isclass(app):
return hasattr(app, "__await__")
elif inspect.isfunction(app):
return asyncio.iscoroutinefunction(app)
return iscoroutinefunction(app)
else:
call = getattr(app, "__call__", None) # noqa
return asyncio.iscoroutinefunction(call)
return iscoroutinefunction(call)


class SentryAsgiMiddleware:
Expand Down
Loading