finalize_request() — flask Function Reference
Architecture documentation for the finalize_request() function in app.py from the flask codebase.
Entity Profile
Dependency Diagram
graph TD 8a660ad5_27c1_9b88_cf57_c82cb644de6c["finalize_request()"] 9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5["Flask"] 8a660ad5_27c1_9b88_cf57_c82cb644de6c -->|defined in| 9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 738c25cf_2aef_f422_7e87_9520ea64ce07["handle_exception()"] 738c25cf_2aef_f422_7e87_9520ea64ce07 -->|calls| 8a660ad5_27c1_9b88_cf57_c82cb644de6c 4deafda5_fb07_c30c_ad12_a72767b1a116["full_dispatch_request()"] 4deafda5_fb07_c30c_ad12_a72767b1a116 -->|calls| 8a660ad5_27c1_9b88_cf57_c82cb644de6c 884e9013_4c15_e8c6_1670_cd7bec14a56f["make_response()"] 8a660ad5_27c1_9b88_cf57_c82cb644de6c -->|calls| 884e9013_4c15_e8c6_1670_cd7bec14a56f f653c3a8_c501_85ce_5865_f14ec4664394["process_response()"] 8a660ad5_27c1_9b88_cf57_c82cb644de6c -->|calls| f653c3a8_c501_85ce_5865_f14ec4664394 style 8a660ad5_27c1_9b88_cf57_c82cb644de6c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/flask/app.py lines 1020–1050
def finalize_request(
self,
ctx: AppContext,
rv: ft.ResponseReturnValue | HTTPException,
from_error_handler: bool = False,
) -> Response:
"""Given the return value from a view function this finalizes
the request by converting it into a response and invoking the
postprocessing functions. This is invoked for both normal
request dispatching as well as error handlers.
Because this means that it might be called as a result of a
failure a special safe mode is available which can be enabled
with the `from_error_handler` flag. If enabled, failures in
response processing will be logged and otherwise ignored.
:internal:
"""
response = self.make_response(rv)
try:
response = self.process_response(ctx, response)
request_finished.send(
self, _async_wrapper=self.ensure_sync, response=response
)
except Exception:
if not from_error_handler:
raise
self.logger.exception(
"Request finalizing failed with an error while handling an error"
)
return response
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does finalize_request() do?
finalize_request() is a function in the flask codebase, defined in src/flask/app.py.
Where is finalize_request() defined?
finalize_request() is defined in src/flask/app.py at line 1020.
What does finalize_request() call?
finalize_request() calls 2 function(s): make_response, process_response.
What calls finalize_request()?
finalize_request() is called by 2 function(s): full_dispatch_request, handle_exception.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free