SQLAlchemy session: how to keep it alive?
问题 I have a session object that gets passed around a whole lot and at some point the following lines of code are called (this is unavoidable): import transaction transaction.commit() This renders the session unusable (by closing it I think). My question is two part: How do I check if a session is still alive and well? Is there a quick way to revitalize a dead session? For 2: The only way I currently know is to use sqlalchemy.orm.scoped_session, then call query(...)get(id) many times to recreate