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: Setup the job and results queues.
  
  Args:
      n_parallel: (optional) :obj:`int`. The number of jobs that can be
          run in parallel. Defaults to `None` in which case all but one
          available CPUs will be used.
docstr_tok: ["Setup","the","job","and","results","queues",".","Args",":","n_parallel",":","(","optional",")",":","obj",":","`","int","`",".","The","number","of","jobs","that","can","be","run","in","parallel",".","Defaults","to","`","None","`","in","which","case","all","but","one","available","CPUs","will","be","used","."]
code: def __init__(self, n_parallel: int = None):
      """Setup the job and results queues.
  
      Args:
          n_parallel: (optional) :obj:`int`. The number of jobs that can be
              run in parallel. Defaults to `None` in which case all but one
              available CPUs will be used.
      """
      self._job_queue = mp.Queue()
      self._result_queue = mp.Queue()
      self._is_queue_closed = False
  
      if n_parallel is None:
          self.n_parallel = -2  # using all CPUs but 1
      else:
          self.n_parallel = max(n_parallel, 1)
      self._servant = mp.Process(target=self._run_servant)
      self._interrupt_event = mp.Event()
      self._servant.start()
  
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 1 to create a new Scheduler object  with example: obj = Scheduler(n_parallel)