From 5b18fb6b12ca9b77084130f9628327ddb913384b Mon Sep 17 00:00:00 2001 From: Mike Degatano Date: Sat, 1 Mar 2025 10:46:11 -0500 Subject: [PATCH] No executor task in sentry call when not initialized (#5703) --- supervisor/utils/sentry.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/supervisor/utils/sentry.py b/supervisor/utils/sentry.py index aae6118ed..85619b074 100644 --- a/supervisor/utils/sentry.py +++ b/supervisor/utils/sentry.py @@ -62,9 +62,10 @@ async def async_capture_event(event: dict[str, Any], only_once: str | None = Non Safe to call from event loop. """ - await asyncio.get_running_loop().run_in_executor( - None, capture_event, event, only_once - ) + if sentry_sdk.is_initialized(): + await asyncio.get_running_loop().run_in_executor( + None, capture_event, event, only_once + ) def capture_exception(err: Exception) -> None: @@ -81,7 +82,10 @@ async def async_capture_exception(err: Exception) -> None: Safe to call in event loop. """ - await asyncio.get_running_loop().run_in_executor(None, capture_exception, err) + if sentry_sdk.is_initialized(): + await asyncio.get_running_loop().run_in_executor( + None, sentry_sdk.capture_exception, err + ) def close_sentry() -> None: