def METHOD_NAME(self):
    with self._cond:
        if not self._unfinished_tasks.acquire(False):
            raise ValueError('task_done() called too many times')
        if self._unfinished_tasks.get_value() == 0:
            self._cond.notify_all()