def METHOD_NAME(self, timeout):
    self.all_tasks_done.acquire()
    try:
        endtime = time.time() + timeout
        while self.unfinished_tasks:
            remaining = endtime - time.time()
            if remaining <= 0.0:
                raise self.NotFinished
            self.all_tasks_done.wait(remaining)
    finally:
        self.all_tasks_done.release()