# cwltool.executors

Single and multi-threaded executors.

## Attributes

`TMPDIR_LOCK` |

## Classes

`JobExecutor` | Abstract base job executor.
`SingleJobExecutor` | Default single-threaded CWL reference executor.
`MultithreadedJobExecutor` | Experimental multi-threaded CWL executor.
`NoopJobExecutor` | Do nothing executor, for testing purposes only.

## Module Contents

cwltool.executors.TMPDIR_LOCK

class cwltool.executors.JobExecutor

  Abstract base job executor.

  final_output: collections.abc.MutableSequence[cwl_utils.types.CWLObjectType | None] = []
  final_status: list[str] = []
  output_dirs: set[str]
  __call__(process, job_order_object, runtime_context, logger=_logger)
    Parameters:

      - process (cwltool.process.Process)

      - job_order_object (cwl_utils.types.CWLObjectType)

      - runtime_context (cwltool.context.RuntimeContext)

      - logger (logging.Logger)

    Return type:

      tuple[cwl_utils.types.CWLObjectType | None, str]

  output_callback(out, process_status)

    Collect the final status and outputs.

    Parameters:

      - out (cwl_utils.types.CWLObjectType | None)

      - process_status (str)

    Return type:

      None

  abstractmethod run_jobs(process, job_order_object, logger, runtime_context)

    Execute the jobs for the given Process.

    Parameters:

      - process (cwltool.process.Process)

      - job_order_object (cwl_utils.types.CWLObjectType)

      - logger (logging.Logger)

      - runtime_context (cwltool.context.RuntimeContext)

    Return type:

      None

  execute(process, job_order_object, runtime_context, logger=_logger)

    Execute the process.

    Parameters:

      - process (cwltool.process.Process)

      - job_order_object (cwl_utils.types.CWLObjectType)

      - runtime_context (cwltool.context.RuntimeContext)

      - logger (logging.Logger)

    Return type:

      tuple[cwl_utils.types.CWLObjectType | None, str]

class cwltool.executors.SingleJobExecutor

  Bases: `JobExecutor`

  Default single-threaded CWL reference executor.

  run_jobs(process, job_order_object, logger, runtime_context)

    Execute the jobs for the given Process.

    Parameters:

      - process (cwltool.process.Process)

      - job_order_object (cwl_utils.types.CWLObjectType)

      - logger (logging.Logger)

      - runtime_context (cwltool.context.RuntimeContext)

    Return type:

      None

class cwltool.executors.MultithreadedJobExecutor(max_parallel=0)

  Bases: `JobExecutor`

  Experimental multi-threaded CWL executor.

  Does simple resource accounting, will not start a job unless it has cores / ram available, but does not make any attempt to optimize usage.

  Parameters:

    max_parallel (int)

  exceptions: list[cwltool.errors.WorkflowException] = []
  pending_jobs: list[cwltool.utils.JobsType] = []
  pending_jobs_lock
  max_ram
  max_cores
  max_cuda = 0
  allocated_ram
  allocated_cores
  allocated_cuda: int = 0
  select_resources(request, runtime_context)

    Naïve check for available cpu cores and memory.

    Parameters:

      - request (dict[str, int | float])

      - runtime_context (cwltool.context.RuntimeContext)

    Return type:

      dict[str, int | float]

  run_job(job, runtime_context)

    Execute a single Job in a separate thread.

    Parameters:

      - job (cwltool.utils.JobsType | None)

      - runtime_context (cwltool.context.RuntimeContext)

    Return type:

      None

  wait_for_next_completion(runtime_context)

    Wait for jobs to finish.

    Parameters:

      runtime_context (cwltool.context.RuntimeContext)

    Return type:

      None

  run_jobs(process, job_order_object, logger, runtime_context)

    Execute the jobs for the given Process.

    Parameters:

      - process (cwltool.process.Process)

      - job_order_object (cwl_utils.types.CWLObjectType)

      - logger (logging.Logger)

      - runtime_context (cwltool.context.RuntimeContext)

    Return type:

      None

class cwltool.executors.NoopJobExecutor

  Bases: `JobExecutor`

  Do nothing executor, for testing purposes only.

  run_jobs(process, job_order_object, logger, runtime_context)

    Execute the jobs for the given Process.

    Parameters:

      - process (cwltool.process.Process)

      - job_order_object (cwl_utils.types.CWLObjectType)

      - logger (logging.Logger)

      - runtime_context (cwltool.context.RuntimeContext)

    Return type:

      None

  execute(process, job_order_object, runtime_context, logger=None)

    Execute the process.

    Parameters:

      - process (cwltool.process.Process)

      - job_order_object (cwl_utils.types.CWLObjectType)

      - runtime_context (cwltool.context.RuntimeContext)

      - logger (logging.Logger | None)

    Return type:

      tuple[cwl_utils.types.CWLObjectType | None, str]