From 1e0b383624f493ab9106765557413eddd3cf6016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20HUBSCHER?= Date: Wed, 17 Dec 2025 11:07:20 +0100 Subject: [PATCH] Use asyncio.to_thread to avoid Deadlock error sending to Sentry --- sentry/interceptor.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sentry/interceptor.py b/sentry/interceptor.py index d016acef4..988770916 100644 --- a/sentry/interceptor.py +++ b/sentry/interceptor.py @@ -13,6 +13,7 @@ ) with workflow.unsafe.imports_passed_through(): + import asyncio import sentry_sdk @@ -43,7 +44,7 @@ async def execute_activity(self, input: ExecuteActivityInput) -> Any: if is_dataclass(arg) and not isinstance(arg, type): scope.set_context("temporal.activity.input", asdict(arg)) scope.set_context("temporal.activity.info", activity.info().__dict__) - scope.capture_exception() + await asyncio.to_thread(scope.capture_exception, e) raise e @@ -71,7 +72,7 @@ async def execute_workflow(self, input: ExecuteWorkflowInput) -> Any: scope.set_context("temporal.workflow.info", workflow.info().__dict__) if not workflow.unsafe.is_replaying(): with workflow.unsafe.sandbox_unrestricted(): - scope.capture_exception() + await asyncio.to_thread(scope.capture_exception, e) raise e