From bf104249bf3a49a8a3854f1bac76819e7747277b Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Wed, 5 Aug 2026 13:49:34 +0200 Subject: [PATCH] ref(tornado): Remove unused compat code --- sentry_sdk/integrations/tornado.py | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/sentry_sdk/integrations/tornado.py b/sentry_sdk/integrations/tornado.py index 96c2298139..d4bd9d9798 100644 --- a/sentry_sdk/integrations/tornado.py +++ b/sentry_sdk/integrations/tornado.py @@ -1,6 +1,5 @@ import contextlib import weakref -from inspect import iscoroutinefunction import sentry_sdk from sentry_sdk.api import continue_trace @@ -30,7 +29,6 @@ try: from tornado import version_info as TORNADO_VERSION - from tornado.gen import coroutine from tornado.web import HTTPError, RequestHandler except ImportError: raise DidNotEnable("Tornado not installed") @@ -56,26 +54,11 @@ def setup_once() -> None: old_execute = RequestHandler._execute - awaitable = iscoroutinefunction(old_execute) - - if awaitable: - # Starting Tornado 6 RequestHandler._execute method is a standard Python coroutine (async/await) - # In that case our method should be a coroutine function too - async def sentry_execute_request_handler( - self: "RequestHandler", *args: "Any", **kwargs: "Any" - ) -> "Any": - with _handle_request_impl(self): - return await old_execute(self, *args, **kwargs) - - else: - - @coroutine # type: ignore - def sentry_execute_request_handler( - self: "RequestHandler", *args: "Any", **kwargs: "Any" - ) -> "Any": - with _handle_request_impl(self): - result = yield from old_execute(self, *args, **kwargs) - return result + async def sentry_execute_request_handler( + self: "RequestHandler", *args: "Any", **kwargs: "Any" + ) -> "Any": + with _handle_request_impl(self): + return await old_execute(self, *args, **kwargs) RequestHandler._execute = sentry_execute_request_handler