File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 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):
8181 if cont_len :
8282 segment .put_http_meta (http .CONTENT_LENGTH , int (cont_len ))
8383
84+ if response .status_code >= 500 :
85+ return response
86+
8487 if self .in_lambda_ctx :
8588 self ._recorder .end_subsegment ()
8689 else :
Original file line number Diff line number Diff line change @@ -39,8 +39,11 @@ def template():
3939recorder .configure (service = 'test' , sampling = False , context = Context ())
4040XRayMiddleware (app , recorder )
4141
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.
4447app = app .test_client ()
4548
4649BASE_URL = 'http://localhost{}'
You can’t perform that action at this time.
0 commit comments