Home / Function/ do_teardown_request() — flask Function Reference

do_teardown_request() — flask Function Reference

Architecture documentation for the do_teardown_request() function in app.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  4d256419_1a27_7374_504e_d3f347cc6327["do_teardown_request()"]
  9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5["Flask"]
  4d256419_1a27_7374_504e_d3f347cc6327 -->|defined in| 9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5
  c03b3eb7_5e70_0ee6_2d39_454cca5a0f61["pop()"]
  c03b3eb7_5e70_0ee6_2d39_454cca5a0f61 -->|calls| 4d256419_1a27_7374_504e_d3f347cc6327
  a89c0022_4807_bf16_9be1_6a66f3c78c9f["ensure_sync()"]
  4d256419_1a27_7374_504e_d3f347cc6327 -->|calls| a89c0022_4807_bf16_9be1_6a66f3c78c9f
  style 4d256419_1a27_7374_504e_d3f347cc6327 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/flask/app.py lines 1419–1441

    def do_teardown_request(
        self, ctx: AppContext, exc: BaseException | None = None
    ) -> None:
        """Called after the request is dispatched and the response is finalized,
        right before the request context is popped. Called by
        :meth:`.AppContext.pop`.

        This calls all functions decorated with :meth:`teardown_request`, and
        :meth:`Blueprint.teardown_request` if a blueprint handled the request.
        Finally, the :data:`request_tearing_down` signal is sent.

        :param exc: An unhandled exception raised while dispatching the request.
            Passed to each teardown function.

        .. versionchanged:: 0.9
            Added the ``exc`` argument.
        """
        for name in chain(ctx.request.blueprints, (None,)):
            if name in self.teardown_request_funcs:
                for func in reversed(self.teardown_request_funcs[name]):
                    self.ensure_sync(func)(exc)

        request_tearing_down.send(self, _async_wrapper=self.ensure_sync, exc=exc)

Subdomains

Defined In

Called By

Frequently Asked Questions

What does do_teardown_request() do?
do_teardown_request() is a function in the flask codebase, defined in src/flask/app.py.
Where is do_teardown_request() defined?
do_teardown_request() is defined in src/flask/app.py at line 1419.
What does do_teardown_request() call?
do_teardown_request() calls 1 function(s): ensure_sync.
What calls do_teardown_request()?
do_teardown_request() is called by 1 function(s): pop.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free