Method: flask.app.Flask.do_teardown_appcontext
Calls: 580, Exceptions: 0, Paths: 2Back
Path 1: 573 calls (0.99)
None (537) ZeroDivisionError (12) TypeError (5) KeyError (4) BadRequestKeyError (2) Exception (2) TestGenericHandlers.Custom (2) ValueError (1) Keyboa...
1def do_teardown_appcontext(
2 self, exc: BaseException | None = _sentinel # type: ignore
3 ) -> None:
4 """Called right before the application context is popped.
5
6 When handling a request, the application context is popped
7 after the request context. See :meth:`do_teardown_request`.
8
9 This calls all functions decorated with
10 :meth:`teardown_appcontext`. Then the
11 :data:`appcontext_tearing_down` signal is sent.
12
13 This is called by
14 :meth:`AppContext.pop() <flask.ctx.AppContext.pop>`.
15
16 .. versionadded:: 0.9
17 """
18 if exc is _sentinel:
19 exc = sys.exc_info()[1]
20
21 for func in reversed(self.teardown_appcontext_funcs):
22 self.ensure_sync(func)(exc)
23
24 appcontext_tearing_down.send(self, _async_wrapper=self.ensure_sync, exc=exc)
Path 2: 7 calls (0.01)
None (6) ValueError (1)
1def do_teardown_appcontext(
2 self, exc: BaseException | None = _sentinel # type: ignore
3 ) -> None:
4 """Called right before the application context is popped.
5
6 When handling a request, the application context is popped
7 after the request context. See :meth:`do_teardown_request`.
8
9 This calls all functions decorated with
10 :meth:`teardown_appcontext`. Then the
11 :data:`appcontext_tearing_down` signal is sent.
12
13 This is called by
14 :meth:`AppContext.pop() <flask.ctx.AppContext.pop>`.
15
16 .. versionadded:: 0.9
17 """
18 if exc is _sentinel:
19 exc = sys.exc_info()[1]
20
21 for func in reversed(self.teardown_appcontext_funcs):
22 self.ensure_sync(func)(exc)
23
24 appcontext_tearing_down.send(self, _async_wrapper=self.ensure_sync, exc=exc)