ensure context cleanup runs even if teardown raises
This commit is contained in:
parent
7b0088693e
commit
913b2b6a35
1 changed files with 10 additions and 6 deletions
|
|
@ -484,13 +484,17 @@ class AppContext:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if self._request is not None:
|
if self._request is not None:
|
||||||
self.app.do_teardown_request(self, exc)
|
try:
|
||||||
self._request.close()
|
self.app.do_teardown_request(self, exc)
|
||||||
|
finally:
|
||||||
|
self._request.close()
|
||||||
finally:
|
finally:
|
||||||
self.app.do_teardown_appcontext(self, exc)
|
try:
|
||||||
_cv_app.reset(self._cv_token)
|
self.app.do_teardown_appcontext(self, exc)
|
||||||
self._cv_token = None
|
finally:
|
||||||
appcontext_popped.send(self.app, _async_wrapper=self.app.ensure_sync)
|
_cv_app.reset(self._cv_token)
|
||||||
|
self._cv_token = None
|
||||||
|
appcontext_popped.send(self.app, _async_wrapper=self.app.ensure_sync)
|
||||||
|
|
||||||
def __enter__(self) -> te.Self:
|
def __enter__(self) -> te.Self:
|
||||||
self.push()
|
self.push()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue