def join(self) -> None:
        """Waiting until all tasks are finished."""
        while True:
            all_finished = True
            current_time = time.time()
            for task in self._queue:
                all_finished = all_finished and task.is_finished()
                if task._idx in self._finished_tasks:
                    continue
                if task.is_running() is False:
                    next_dev = self._devs.next_idle_dev()
                    if next_dev is None:
                        continue
                    task(next_dev)
                    continue
                if task.poll(current_time, self._timeout):
                    self._devs.reset_dev_state(task.assigned_dev())
                    self._finished_tasks.add(task._idx)
            if all_finished:
                break
Waiting until all tasks are finished.
python/aitemplate/backend/task_runner.py