code: def _commit_unless_raises(cls, write_target_db: BaseDB) -> Iterator['AtomicDBWriteBatch']:
          
          readable_write_batch = cls(write_target_db)     # type: AtomicDBWriteBatch
          try:
              yield readable_write_batch
          except Exception:
              cls.logger.exception(
                  "Unexpected error in atomic db write, dropped partial writes: %r",
                  readable_write_batch._diff(),
              )
              raise
          else:
              readable_write_batch._commit()
          finally:
              # force a shutdown of this batch, to prevent out-of-context usage
              readable_write_batch._track_diff = None
              readable_write_batch._write_target_db = None
docs: Commit all writes inside the context, unless an exception was raised.
  
          Although this is technically an external API, it (and this whole class) is only intended
          to be used by AtomicDB.