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:
|
||||
if self._request is not None:
|
||||
self.app.do_teardown_request(self, exc)
|
||||
self._request.close()
|
||||
try:
|
||||
self.app.do_teardown_request(self, exc)
|
||||
finally:
|
||||
self._request.close()
|
||||
finally:
|
||||
self.app.do_teardown_appcontext(self, exc)
|
||||
_cv_app.reset(self._cv_token)
|
||||
self._cv_token = None
|
||||
appcontext_popped.send(self.app, _async_wrapper=self.app.ensure_sync)
|
||||
try:
|
||||
self.app.do_teardown_appcontext(self, exc)
|
||||
finally:
|
||||
_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:
|
||||
self.push()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue