

@contextlib.contextmanager
def _connection(self, savepoint=False):
    if (self.connection is None):
        try:
            if (self.session is not None):
                self.connection = self.session.connection()
                if savepoint:
                    with self.connection.begin_nested():
                        (yield self.connection)
                else:
                    (yield self.connection)
            else:
                self.connection = self.factory._create_connection(mode=self.mode)
                self.transaction = self.connection.begin()
                try:
                    (yield self.connection)
                    self._end_connection_transaction(self.transaction)
                except Exception:
                    self.transaction.rollback()
                    raise
                finally:
                    self.transaction = None
                    self.connection.close()
        finally:
            self.connection = None
    elif savepoint:
        with savepoint.connection.begin_nested():
            (yield self.connection)
    else:
        (yield self.connection)

dataset/ETHPy150Open openstack/oslo.db/oslo_db/sqlalchemy/enginefacade.py _TransactionContext._connection/VarMisuse@205/234 `self`->`savepoint`