Skip to content

Commit 4afb955

Browse files
authored
Guard against sentry initialization mid sqlalchemy cursor (#2702)
1 parent ad86d61 commit 4afb955

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sentry_sdk/integrations/sqlalchemy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def _after_cursor_execute(conn, cursor, statement, parameters, context, *args):
9595
context._sentry_sql_span_manager = None
9696
ctx_mgr.__exit__(None, None, None)
9797

98-
span = context._sentry_sql_span
98+
span = getattr(context, "_sentry_sql_span", None) # type: Optional[Span]
9999
if span is not None:
100100
with capture_internal_exceptions():
101101
add_query_source(hub, span)

0 commit comments

Comments
 (0)