Skip to content

Commit 5b18fb6

Browse files
authored
No executor task in sentry call when not initialized (#5703)
1 parent d42ec12 commit 5b18fb6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

supervisor/utils/sentry.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ async def async_capture_event(event: dict[str, Any], only_once: str | None = Non
6262
6363
Safe to call from event loop.
6464
"""
65-
await asyncio.get_running_loop().run_in_executor(
66-
None, capture_event, event, only_once
67-
)
65+
if sentry_sdk.is_initialized():
66+
await asyncio.get_running_loop().run_in_executor(
67+
None, capture_event, event, only_once
68+
)
6869

6970

7071
def capture_exception(err: Exception) -> None:
@@ -81,7 +82,10 @@ async def async_capture_exception(err: Exception) -> None:
8182
8283
Safe to call in event loop.
8384
"""
84-
await asyncio.get_running_loop().run_in_executor(None, capture_exception, err)
85+
if sentry_sdk.is_initialized():
86+
await asyncio.get_running_loop().run_in_executor(
87+
None, sentry_sdk.capture_exception, err
88+
)
8589

8690

8791
def close_sentry() -> None:

0 commit comments

Comments
 (0)