code: def _do_write(self):
          
          with self.lock:
              self._commit_counter += 1
              if self._commit_counter >= self._commit_every:
                  self._db.commit()
                  self._commit_counter = 0
docs: Check commit counter and do a commit if need be