<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _do_write(self):
 """ Check commit counter and do a commit if need be """

        with self.lock:
            self._commit_counter += 1
            if self._commit_counter >= self._commit_every:
                self._db.commit()
                self._commit_counter = 0