File tree 2 files changed +8
-2
lines changed
2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,9 @@ def _after_request(self, response):
81
81
if cont_len :
82
82
segment .put_http_meta (http .CONTENT_LENGTH , int (cont_len ))
83
83
84
+ if response .status_code >= 500 :
85
+ return response
86
+
84
87
if self .in_lambda_ctx :
85
88
self ._recorder .end_subsegment ()
86
89
else :
Original file line number Diff line number Diff line change @@ -39,8 +39,11 @@ def template():
39
39
recorder .configure (service = 'test' , sampling = False , context = Context ())
40
40
XRayMiddleware (app , recorder )
41
41
42
- # enable testing mode
43
- app .config ['TESTING' ] = True
42
+ # We don't need to enable testing mode by doing app.config['TESTING'] = True
43
+ # because what it does is disable error catching during request handling,
44
+ # so that you get better error reports when performing test requests against the application.
45
+ # But this also results in `after_request` method not getting invoked during unhandled exception which we want
46
+ # since it is the actual application behavior in our use case.
44
47
app = app .test_client ()
45
48
46
49
BASE_URL = 'http://localhost{}'
You can’t perform that action at this time.
0 commit comments