Skip to content

Commit 2452820

Browse files
committed
Finish the transaction using same scopes as when creating them
1 parent f306e48 commit 2452820

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

sentry_sdk/integrations/wsgi.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,12 @@ def __iter__(self):
273273
yield chunk
274274

275275
finally:
276-
# Close the Sentry transaction (it could be that response.close() is never called by the framework)
277-
# This is done here to make sure the Transaction stays
278-
# open until all streaming responses are done.
279-
finish_running_transaction(self._current_scope)
276+
with use_isolation_scope(self._isolation_scope):
277+
with use_scope(self._current_scope):
278+
# Close the Sentry transaction (it could be that response.close() is never called by the framework)
279+
# This is done here to make sure the Transaction stays
280+
# open until all streaming responses are done.
281+
finish_running_transaction(self._current_scope)
280282

281283
def close(self):
282284
# type: () -> None

0 commit comments

Comments
 (0)