Best way to split the work is one function, one job. Update the user - 1 route, add new job listing - 1 route, etc...
And dependacies should be resolved at route level as that is how FastAPI works
You dependacies are created when request comes and destroyed when response leaves. Its request-based scoping.
An no, the
get_session is not running the whole time, yield returnes the result and stops execution of functionYou should learn about
yield and how it works to understand get_session.This article seams resonable to learn from
https://amitamola.medium.com/understanding-yield-in-python-b11e7e23d674