File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,9 @@ def wrapped_callback(*args, **kwargs):
138138 ):
139139 _capture_exception (res , handled = True )
140140
141+ # Manually close the transaction because Bottle does not call `close()` on the WSGI response
142+ sentry_sdk .get_current_scope ().transaction .__exit__ (None , None , None )
143+
141144 return res
142145
143146 return wrapped_callback
Original file line number Diff line number Diff line change @@ -269,6 +269,12 @@ def __iter__(self):
269269
270270 yield chunk
271271
272+ # Close the Sentry transaction (it could be that response.close() is never called by the framework)
273+ # This is done here to make sure the Transaction stays
274+ # open until all streaming responses are done.
275+ if self ._transaction is not None :
276+ self ._transaction .__exit__ (None , None , None )
277+
272278 def close (self ):
273279 # type: () -> None
274280 with use_isolation_scope (self ._isolation_scope ):
@@ -279,9 +285,8 @@ def close(self):
279285 # Close the Sentry transaction
280286 # This is done here to make sure the Transaction stays
281287 # open until all streaming responses are done.
282- # Of course this here works also for non streaming responses.
283288 if self ._transaction is not None :
284- self ._transaction .__exit__ (None , None , None )
289+ self ._transaction .__exit__ (None , None , None )
285290 except AttributeError :
286291 pass
287292 except BaseException :
You can’t perform that action at this time.
0 commit comments