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

Method pop

src/flask/ctx.py:256–272  ·  src/flask/ctx.py::AppContext.pop

Pops the app context.

(self, exc: BaseException | None = _sentinel)

Source from the content-addressed store, hash-verified

254 appcontext_pushed.send(self.app, _async_wrapper=self.app.ensure_sync)
255
256 def pop(self, exc: BaseException | None = _sentinel) -> None: class="cm"># type: ignore
257 class="st">""class="st">"Pops the app context."class="st">""
258 try:
259 if len(self._cv_tokens) == 1:
260 if exc is _sentinel:
261 exc = sys.exc_info()[1]
262 self.app.do_teardown_appcontext(exc)
263 finally:
264 ctx = _cv_app.get()
265 _cv_app.reset(self._cv_tokens.pop())
266
267 if ctx is not self:
268 raise AssertionError(
269 fclass="st">"Popped wrong app context. ({ctx!r} instead of {self!r})"
270 )
271
272 appcontext_popped.send(self.app, _async_wrapper=self.app.ensure_sync)
273
274 def __enter__(self) -> AppContext:
275 self.push()

Callers 15

__exit__Method · 0.95
commandMethod · 0.45
__init__Method · 0.45
popMethod · 0.45
popMethod · 0.45
get_flashed_messagesFunction · 0.45
wsgi_appMethod · 0.45
decoratorMethod · 0.45
add_url_ruleMethod · 0.45
add_url_ruleMethod · 0.45
test_teardown_on_popFunction · 0.45
test_context_testFunction · 0.45

Calls 2

getMethod · 0.45

Tested by 15

test_teardown_on_popFunction · 0.36
test_context_testFunction · 0.36
pull_lang_codeFunction · 0.36
app_teardown1Function · 0.36
app_teardown2Function · 0.36
parent_teardown1Function · 0.36
parent_teardown2Function · 0.36
child_teardown1Function · 0.36
child_teardown2Function · 0.36
clearFunction · 0.36