Method: flask.app.Flask.finalize_request
Calls: 414, Exceptions: 9, Paths: 4Back
Path 1: 405 calls (0.98)
Response (52) '' (19) 'GET' (19) MethodNotAllowed (15) 'POST' (12) ('', 204) (12) NotFound (11) '3' (9) 'dcba' (9) '\n Success!\n' (9)
False (389) True (16)
Response (405)
1def finalize_request(
2 self,
3 rv: ft.ResponseReturnValue | HTTPException,
4 from_error_handler: bool = False,
5 ) -> Response:
6 """Given the return value from a view function this finalizes
7 the request by converting it into a response and invoking the
8 postprocessing functions. This is invoked for both normal
9 request dispatching as well as error handlers.
10
11 Because this means that it might be called as a result of a
12 failure a special safe mode is available which can be enabled
13 with the `from_error_handler` flag. If enabled, failures in
14 response processing will be logged and otherwise ignored.
15
16 :internal:
17 """
18 response = self.make_response(rv)
19 try:
20 response = self.process_response(response)
21 request_finished.send(
22 self, _async_wrapper=self.ensure_sync, response=response
23 )
24 except Exception:
25 if not from_error_handler:
26 raise
27 self.logger.exception(
28 "Request finalizing failed with an error while handling an error"
29 )
30 return response
Path 2: 5 calls (0.01)
None (1) ('Hello',) (1) tuple (1) True (1) test_response_type_errors.
False (5)
TypeError (5)
1def finalize_request(
2 self,
3 rv: ft.ResponseReturnValue | HTTPException,
4 from_error_handler: bool = False,
5 ) -> Response:
6 """Given the return value from a view function this finalizes
7 the request by converting it into a response and invoking the
8 postprocessing functions. This is invoked for both normal
9 request dispatching as well as error handlers.
10
11 Because this means that it might be called as a result of a
12 failure a special safe mode is available which can be enabled
13 with the `from_error_handler` flag. If enabled, failures in
14 response processing will be logged and otherwise ignored.
15
16 :internal:
17 """
18 response = self.make_response(rv)
19 try:
20 response = self.process_response(response)
21 request_finished.send(
22 self, _async_wrapper=self.ensure_sync, response=response
23 )
24 except Exception:
25 if not from_error_handler:
26 raise
27 self.logger.exception(
28 "Request finalizing failed with an error while handling an error"
29 )
30 return response
Path 3: 2 calls (0.0)
'Hello World' (1) 'Foo' (1)
False (2)
ValueError (1) ZeroDivisionError (1)
1def finalize_request(
2 self,
3 rv: ft.ResponseReturnValue | HTTPException,
4 from_error_handler: bool = False,
5 ) -> Response:
6 """Given the return value from a view function this finalizes
7 the request by converting it into a response and invoking the
8 postprocessing functions. This is invoked for both normal
9 request dispatching as well as error handlers.
10
11 Because this means that it might be called as a result of a
12 failure a special safe mode is available which can be enabled
13 with the `from_error_handler` flag. If enabled, failures in
14 response processing will be logged and otherwise ignored.
15
16 :internal:
17 """
18 response = self.make_response(rv)
19 try:
20 response = self.process_response(response)
21 request_finished.send(
22 self, _async_wrapper=self.ensure_sync, response=response
23 )
24 except Exception:
25 if not from_error_handler:
26 raise
27 self.logger.exception(
28 "Request finalizing failed with an error while handling an error"
29 )
30 return response
Path 4: 2 calls (0.0)
('Hello Server Error', 500) (1) InternalServerError (1)
True (2)
Response (2)
ZeroDivisionError (1) NotImplementedError (1)
1def finalize_request(
2 self,
3 rv: ft.ResponseReturnValue | HTTPException,
4 from_error_handler: bool = False,
5 ) -> Response:
6 """Given the return value from a view function this finalizes
7 the request by converting it into a response and invoking the
8 postprocessing functions. This is invoked for both normal
9 request dispatching as well as error handlers.
10
11 Because this means that it might be called as a result of a
12 failure a special safe mode is available which can be enabled
13 with the `from_error_handler` flag. If enabled, failures in
14 response processing will be logged and otherwise ignored.
15
16 :internal:
17 """
18 response = self.make_response(rv)
19 try:
20 response = self.process_response(response)
21 request_finished.send(
22 self, _async_wrapper=self.ensure_sync, response=response
23 )
24 except Exception:
25 if not from_error_handler:
26 raise
27 self.logger.exception(
28 "Request finalizing failed with an error while handling an error"
29 )
30 return response