This website requires JavaScript.
Explore
Sign In
skills
/
fastapi__fastapi
Watch
1
Star
0
Fork
0
You've already forked fastapi__fastapi
mirror of
https://github.com/fastapi/fastapi.git
synced
2026-09-14 13:36:21 +08:00
Code
Issues
Packages
Projects
Releases
Wiki
Activity
Files
8f82c94de0ff641a239db59e58dfdc6010a4b26a
fastapi__fastapi
/
docs_src
/
dependencies
/
tutorial007_py39.py
T
7 lines
99 B
Python
Raw
Normal View
History
Unescape
Escape
:sparkles: Add dependencies with yield (used as context managers) (#595) * :heavy_plus_sign: Add development/testing dependencies for Python 3.6 * :sparkles: Add concurrency submodule with contextmanager_in_threadpool * :sparkles: Add AsyncExitStack to ASGI scope in FastAPI app call * :sparkles: Use async stack for contextmanager-able dependencies including running in threadpool sync dependencies * :white_check_mark: Add tests for contextmanager dependencies including internal raise checks when exceptions should be handled and when not * :white_check_mark: Add test for fake asynccontextmanager raiser * :bug: Fix mypy errors and coverage * :mute: Remove development logs and prints * :white_check_mark: Add tests for sub-contextmanagers, background tasks, and sync functions * :bug: Fix mypy errors for Python 3.7 * :speech_balloon: Fix error texts for clarity * :memo: Add docs for dependencies with yield * :sparkles: Update SQL with SQLAlchemy tutorial to use dependencies with yield and add an alternative with a middleware (from the old tutorial) * :white_check_mark: Update SQL tests to remove DB file during the same tests * :white_check_mark: Add tests for example with middleware as a copy from the tests with dependencies with yield, removing the DB in the tests * :pencil2: Fix typos with suggestions from code review Co-Authored-By: dmontagu <35119617+dmontagu@users.noreply.github.com>
2019-10-09 13:01:58 -05:00
async
def
get_db
(
)
:
db
=
DBSession
(
)
try
:
yield
db
finally
:
db
.
close
(
)
Reference in New Issue
Copy Permalink