]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commit
✨ Add support for raising exceptions (including `HTTPException`) in dependencies...
authorSebastián Ramírez <tiangolo@gmail.com>
Mon, 25 Dec 2023 17:57:35 +0000 (18:57 +0100)
committerGitHub <noreply@github.com>
Mon, 25 Dec 2023 17:57:35 +0000 (18:57 +0100)
commita4aa79e0b4cacc6b428d415d04d234a8c77af9d5
treecad9b58861ddce33b853d77bf885a408bb145ebe
parente7756ae7dcffa0b73767d354ca158fd6b7bc87ed
✨ Add support for raising exceptions (including `HTTPException`) in dependencies with `yield` in the exit code, do not support them in background tasks (#10831)

* ♻️ Refactor dependency AsyncExitStack logic, exit dependencies after creating the response, before sending it

* ✅ Update tests for dependencies exit, check they are finished before the response is sent

* 🔥 Remove ExitAsyncStackMiddleware as it's no longer needed

* 📝 Update docs for dependencies with yield

* 📝 Update release notes

* 📝 Add source examples for new dependencies with yield raising

* ✅ Add tests for new dependencies raising after yield

* 📝 Update release notes
15 files changed:
docs/en/docs/release-notes.md
docs/en/docs/tutorial/dependencies/dependencies-with-yield.md
docs_src/dependencies/tutorial008b.py [new file with mode: 0644]
docs_src/dependencies/tutorial008b_an.py [new file with mode: 0644]
docs_src/dependencies/tutorial008b_an_py39.py [new file with mode: 0644]
fastapi/applications.py
fastapi/concurrency.py
fastapi/dependencies/utils.py
fastapi/middleware/asyncexitstack.py [deleted file]
fastapi/routing.py
pyproject.toml
tests/test_dependency_contextmanager.py
tests/test_tutorial/test_dependencies/test_tutorial008b.py [new file with mode: 0644]
tests/test_tutorial/test_dependencies/test_tutorial008b_an.py [new file with mode: 0644]
tests/test_tutorial/test_dependencies/test_tutorial008b_an_py39.py [new file with mode: 0644]