run_tasks

sherpa.utils.parallel.run_tasks(procs: Sequence[SupportsProcess], err_q: SupportsQueue[Exception], out_q: SupportsQueue[tuple[int, list[O_co]]], num: Any | None = None) list[O_co][source] [edit on github]

Run the processes, exiting early if necessary, and return the results.

Changed in version 4.16.0: The num argument is not needed and has been marked optional. It will be removed in a future release.

Parameters:
  • procs (list of multiprocessing.Process tasks) – The processes to run.

  • err_q (manager.Queue) – The error and success channels used by the processes.

  • out_q (manager.Queue) – The error and success channels used by the processes.

  • num (optional) – This argument is unused and will be removed.

Returns:

result – The result from the processes. This may contain more elements than procs, as each process may return multiple results.

Return type:

list

Notes

Each process sends its output - a pair with index and a list of results - to the out_q queue, and any error encounteded to the err_q queue. There should be len(procs) messages sent to the out_q queue for a successful run.