I wanted to understand what this yield does. In the examples I find, I always see this type of code, but I don't understand what it differs from a normal instance
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
This example is in the FastAPI documentation: https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-with-yield/