Skip to content

Commit b8ecfbb

Browse files
authored
Use asyncio.to_thread to avoid Deadlock error sending to Sentry
1 parent 5140187 commit b8ecfbb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sentry/interceptor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
)
1414

1515
with workflow.unsafe.imports_passed_through():
16+
import asyncio
1617
import sentry_sdk
1718

1819

@@ -43,7 +44,7 @@ async def execute_activity(self, input: ExecuteActivityInput) -> Any:
4344
if is_dataclass(arg) and not isinstance(arg, type):
4445
scope.set_context("temporal.activity.input", asdict(arg))
4546
scope.set_context("temporal.activity.info", activity.info().__dict__)
46-
scope.capture_exception()
47+
await asyncio.to_thread(scope.capture_exception)
4748
raise e
4849

4950

@@ -71,7 +72,7 @@ async def execute_workflow(self, input: ExecuteWorkflowInput) -> Any:
7172
scope.set_context("temporal.workflow.info", workflow.info().__dict__)
7273
if not workflow.unsafe.is_replaying():
7374
with workflow.unsafe.sandbox_unrestricted():
74-
scope.capture_exception()
75+
await asyncio.to_thread(scope.capture_exception)
7576
raise e
7677

7778

0 commit comments

Comments
 (0)