

@contextlib.contextmanager
def _session(self, savepoint=False):
    if (self.session is None):
        self.session = self.factory._create_session(bind=self.connection, mode=self.mode)
        try:
            self.session.begin()
            (yield self.session)
            self._end_session_transaction(self.session)
        except Exception:
            self.session.rollback()
            raise
        finally:
            self.session.close()
            self.session = None
    elif savepoint:
        with savepoint.session.begin_nested():
            (yield self.session)
    else:
        (yield self.session)

dataset/ETHPy150Open openstack/oslo.db/oslo_db/sqlalchemy/enginefacade.py _TransactionContext._session/VarMisuse@124/138 `self`->`savepoint`