MCPcopy
hub / github.com/pallets/flask / do_teardown_appcontext

Method do_teardown_appcontext

src/flask/app.py:1360–1384  ·  view source on GitHub ↗

Called right before the application context is popped. When handling a request, the application context is popped after the request context. See :meth:`do_teardown_request`. This calls all functions decorated with :meth:`teardown_appcontext`. Then the :data:

(
        self,
        exc: BaseException | None = _sentinel,  # type: ignore[assignment]
    )

Source from the content-addressed store, hash-verified

1358 request_tearing_down.send(self, _async_wrapper=self.ensure_sync, exc=exc)
1359
1360 def do_teardown_appcontext(
1361 self,
1362 exc: BaseException | None = _sentinel, # type: ignore[assignment]
1363 ) -> None:
1364 """Called right before the application context is popped.
1365
1366 When handling a request, the application context is popped
1367 after the request context. See :meth:`do_teardown_request`.
1368
1369 This calls all functions decorated with
1370 :meth:`teardown_appcontext`. Then the
1371 :data:`appcontext_tearing_down` signal is sent.
1372
1373 This is called by
1374 :meth:`AppContext.pop() <flask.ctx.AppContext.pop>`.
1375
1376 .. versionadded:: 0.9
1377 """
1378 if exc is _sentinel:
1379 exc = sys.exc_info()[1]
1380
1381 for func in reversed(self.teardown_appcontext_funcs):
1382 self.ensure_sync(func)(exc)
1383
1384 appcontext_tearing_down.send(self, _async_wrapper=self.ensure_sync, exc=exc)
1385
1386 def app_context(self) -> AppContext:
1387 """Create an :class:`~flask.ctx.AppContext`. Use as a ``with``

Callers 1

popMethod · 0.80

Calls 1

ensure_syncMethod · 0.95

Tested by

no test coverage detected