class_docstr: Manages running threads and processes of a Launchpad Program.
class_docstr_tok: ["Manages","running","threads","and","processes","of","a","Launchpad","Program","."]
docstr: Waits until all thread workers finish. Raises errors if any.
  
  Args:
    labels_to_wait_for: labels of the workers to wait for. If None, wait for
      all workers.
docstr_tok: ["Waits","until","all","thread","workers","finish",".","Raises","errors","if","any",".","Args",":","labels_to_wait_for",":","labels","of","the","workers","to","wait","for",".","If","None",",","wait","for","all","workers","."]
code: def wait(self, labels_to_wait_for: Optional[Sequence[str]] = None):
      """Waits until all thread workers finish. Raises errors if any.
  
      Args:
        labels_to_wait_for: labels of the workers to wait for. If None, wait for
          all workers.
      """
      has_active_worker = True
      while has_active_worker:
          try:
              has_active_worker = False
              # Will raise errors, if any.
              self.check_for_thread_worker_exception()
              with self._mutex:
                  # check_for_thread_worker_exception() will update self._thread_workers
                  # so that it only contains active workers. If there are still
                  # non-empty lists, it means some workers have not finished yet.
                  for label, workers in self._thread_workers.items():
                      if (
                          labels_to_wait_for
                          and label not in labels_to_wait_for
                      ):
                          continue
                      if workers:
                          has_active_worker = True
                          break
                  for label, processes in self._process_workers.items():
                      if (
                          labels_to_wait_for
                          and label not in labels_to_wait_for
                      ):
                          continue
                      if processes:
                          has_active_worker = True
                          break
              time.sleep(0.1)
          except KeyboardInterrupt:
              pass
  
imports: import collections
  from concurrent import futures
  import dataclasses
  import functools
  import signal
  import subprocess
  import threading
  import time
  from typing import Any, Callable, Iterable, List, Mapping, MutableMapping, Optional, Sequence, Tuple
  from absl import logging
  from launchpad import flags
  import psutil
  import termcolor
label_desc: Use image node_id 10 for calling the WorkerManager obj's underlying member method code with example usage: obj.wait(labels_to_wait_for) without return types