<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def in_session(self):
 """Provide a session scope around a series of operations."""

        session = self.get_session()
        try:
            yield session
            session.commit()
        except IntegrityError:
            session.rollback()
            raise DuplicateError("Duplicate unique value detected!")
        except (OperationalError, DisconnectionError):
            session.rollback()
            self.close()
            logger.warn("Database Connection Lost!")
            raise DatabaseConnectionError()
        except Exception:
            session.rollback()
            raise
        finally:
            session.close()