Method: flask.app.Flask.do_teardown_request
Calls: 526, Exceptions: 1, Paths: 3Back
Path 1: 512 calls (0.97)
None (475) ZeroDivisionError (11) TypeError (5) KeyError (4) ValueError (2) BadRequestKeyError (2) Exception (2) TestGenericHandlers.Custom (2) Keyboa...
1def do_teardown_request(
2 self, exc: BaseException | None = _sentinel # type: ignore
3 ) -> None:
4 """Called after the request is dispatched and the response is
5 returned, right before the request context is popped.
6
7 This calls all functions decorated with
8 :meth:`teardown_request`, and :meth:`Blueprint.teardown_request`
9 if a blueprint handled the request. Finally, the
10 :data:`request_tearing_down` signal is sent.
11
12 This is called by
13 :meth:`RequestContext.pop() <flask.ctx.RequestContext.pop>`,
14 which may be delayed during testing to maintain access to
15 resources.
16
17 :param exc: An unhandled exception raised while dispatching the
18 request. Detected from the current exception information if
19 not passed. Passed to each teardown function.
20
21 .. versionchanged:: 0.9
22 Added the ``exc`` argument.
23 """
24 if exc is _sentinel:
25 exc = sys.exc_info()[1]
26
27 for name in chain(request.blueprints, (None,)):
28 if name in self.teardown_request_funcs:
29 for func in reversed(self.teardown_request_funcs[name]):
30 self.ensure_sync(func)(exc)
31
32 request_tearing_down.send(self, _async_wrapper=self.ensure_sync, exc=exc)
Path 2: 13 calls (0.02)
None (12) ZeroDivisionError (1)
1def do_teardown_request(
2 self, exc: BaseException | None = _sentinel # type: ignore
3 ) -> None:
4 """Called after the request is dispatched and the response is
5 returned, right before the request context is popped.
6
7 This calls all functions decorated with
8 :meth:`teardown_request`, and :meth:`Blueprint.teardown_request`
9 if a blueprint handled the request. Finally, the
10 :data:`request_tearing_down` signal is sent.
11
12 This is called by
13 :meth:`RequestContext.pop() <flask.ctx.RequestContext.pop>`,
14 which may be delayed during testing to maintain access to
15 resources.
16
17 :param exc: An unhandled exception raised while dispatching the
18 request. Detected from the current exception information if
19 not passed. Passed to each teardown function.
20
21 .. versionchanged:: 0.9
22 Added the ``exc`` argument.
23 """
24 if exc is _sentinel:
25 exc = sys.exc_info()[1]
26
27 for name in chain(request.blueprints, (None,)):
28 if name in self.teardown_request_funcs:
29 for func in reversed(self.teardown_request_funcs[name]):
30 self.ensure_sync(func)(exc)
31
32 request_tearing_down.send(self, _async_wrapper=self.ensure_sync, exc=exc)
Path 3: 1 calls (0.0)
None (1)
ZeroDivisionError (1)
1def do_teardown_request(
2 self, exc: BaseException | None = _sentinel # type: ignore
3 ) -> None:
4 """Called after the request is dispatched and the response is
5 returned, right before the request context is popped.
6
7 This calls all functions decorated with
8 :meth:`teardown_request`, and :meth:`Blueprint.teardown_request`
9 if a blueprint handled the request. Finally, the
10 :data:`request_tearing_down` signal is sent.
11
12 This is called by
13 :meth:`RequestContext.pop() <flask.ctx.RequestContext.pop>`,
14 which may be delayed during testing to maintain access to
15 resources.
16
17 :param exc: An unhandled exception raised while dispatching the
18 request. Detected from the current exception information if
19 not passed. Passed to each teardown function.
20
21 .. versionchanged:: 0.9
22 Added the ``exc`` argument.
23 """
24 if exc is _sentinel:
25 exc = sys.exc_info()[1]
26
27 for name in chain(request.blueprints, (None,)):
28 if name in self.teardown_request_funcs:
29 for func in reversed(self.teardown_request_funcs[name]):
30 self.ensure_sync(func)(exc)
31
32 request_tearing_down.send(self, _async_wrapper=self.ensure_sync, exc=exc)