@@ -135,8 +135,10 @@ def __call__(self, environ, start_response):
135135 ),
136136 )
137137 except BaseException :
138- finish_running_transaction (current_scope , sys .exc_info ())
139- reraise (* _capture_exception ())
138+ exc_info = sys .exc_info ()
139+ _capture_exception (exc_info )
140+ finish_running_transaction (current_scope , exc_info )
141+ reraise (* exc_info )
140142
141143 finally :
142144 _wsgi_middleware_applied .set (False )
@@ -207,13 +209,13 @@ def get_client_ip(environ):
207209 return environ .get ("REMOTE_ADDR" )
208210
209211
210- def _capture_exception ():
211- # type: () -> ExcInfo
212+ def _capture_exception (exc_info = None ):
213+ # type: (Optional[ExcInfo] ) -> ExcInfo
212214 """
213215 Captures the current exception and sends it to Sentry.
214216 Returns the ExcInfo tuple to it can be reraised afterwards.
215217 """
216- exc_info = sys .exc_info ()
218+ exc_info = exc_info or sys .exc_info ()
217219 e = exc_info [1 ]
218220
219221 # SystemExit(0) is the only uncaught exception that is expected behavior
@@ -274,6 +276,7 @@ def __iter__(self):
274276 # Close the Sentry transaction (it could be that response.close() is never called by the framework)
275277 # This is done here to make sure the Transaction stays
276278 # open until all streaming responses are done.
279+ import ipdb ; ipdb .set_trace ()
277280 finish_running_transaction (self ._current_scope )
278281
279282 def close (self ):
0 commit comments