class_docstr: A manager for parallel execution of jobs.
  
  A job must be of type :class:`Job` which produces a :class:`Result`
  object upon successful completion. The scheduler maintains a job and
  result queues.
  
  Notes:
      This class should be used as a context manager.
docstr: Collect all the available results or wait until they become available.
  
  Args:
      n_results: :obj:`int`, number of results to wait for.
          If `n_results` ≤ 0 then all available results will be returned.
      timeout: (optional) :obj:`float`, number of seconds to wait for
          results to appear. If None (default) then it will wait until
          all `n_results` are collected.
  
  Returns:
      A list of :class:`Result` objects with length `n_results` at least.
  
  Notes:
      If `n_results` is overestimated and timeout is None, then this
      method will hang forever. Therefore it is recommended that a timeout
      is set.
  
  Raises:
      :obj:`TimeoutError`: if more than `timeout` seconds elapse before a
      :class:`Result` is collected.
docstr_tok: ["Collect","all","the","available","results","or","wait","until","they","become","available",".","Args",":","n_results",":",":","obj",":","`","int","`",",","number","of","results","to","wait","for",".","If","`","n_results","`","\u2264","0","then","all","available","results","will","be","returned",".","timeout",":","(","optional",")",":","obj",":","`","float","`",",","number","of","seconds","to","wait","for","results","to","appear",".","If","None","(","default",")","then","it","will","wait","until","all","`","n_results","`","are","collected",".","Returns",":","A","list","of",":","class",":","`","Result","`","objects","with","length","`","n_results","`","at","least",".","Notes",":","If","`","n_results","`","is","overestimated","and","timeout","is","None",",","then","this","method","will","hang","forever",".","Therefore","it","is","recommended","that","a","timeout","is","set",".","Raises",":",":","obj",":","`","TimeoutError","`",":","if","more","than","`","timeout","`","seconds","elapse","before","a",":","class",":","`","Result","`","is","collected","."]
code: def collect(
      self, n_results: int, timeout: float = None
  ) -> List[Result]:
      """Collect all the available results or wait until they become available.
  
      Args:
          n_results: :obj:`int`, number of results to wait for.
              If `n_results` ≤ 0 then all available results will be returned.
          timeout: (optional) :obj:`float`, number of seconds to wait for
              results to appear. If None (default) then it will wait until
              all `n_results` are collected.
  
      Returns:
          A list of :class:`Result` objects with length `n_results` at least.
  
      Notes:
          If `n_results` is overestimated and timeout is None, then this
          method will hang forever. Therefore it is recommended that a timeout
          is set.
  
      Raises:
          :obj:`TimeoutError`: if more than `timeout` seconds elapse before a
          :class:`Result` is collected.
      """
      if n_results > 0:
          results = []
          for i in range(n_results):
              results.append(
                  self._result_queue.get(block=True, timeout=timeout)
              )
      else:
          results = utils.drain_queue(self._result_queue)
      return results
  
file_path: hypertunity/hypertunity/scheduling/scheduler.py
imports: import multiprocessing
  import time
  from typing import List
  import joblib
  from hypertunity import utils
  from .jobs import Job, Result
label_desc: Use image node_id 7 for calling the Scheduler obj's underlying member method code with example usage: obj.collect(n_results, timeout) and returns: results