pyiron_base.jobs.job.runfunction.run_job_with_runmode_executor_futures

pyiron_base.jobs.job.runfunction.run_job_with_runmode_executor_futures#

pyiron_base.jobs.job.runfunction.run_job_with_runmode_executor_futures(job: pyiron_base.jobs.job.generic.GenericJob, executor: concurrent.futures.Executor) None[source]#

Interface for the ProcessPoolExecutor implemented in the python standard library as part of the concurrent.futures module. The ProcessPoolExecutor does not provide any resource management, so the user is responsible to keep track of the number of compute cores in use, as over-subscription can lead to low performance.

The [ProcessPoolExecutor docs](https://docs.python.org/3/library/concurrent.futures.html#processpoolexecutor) state: “The __main__ module must be importable by worker subprocesses. This means that ProcessPoolExecutor will not work in the interactive interpreter.” (i.e. Jupyter notebooks). For standard usage this is a non-issue, but for the edge case of job classes defined in-notebook (e.g. children of PythonTemplateJob), the using the ProcessPoolExecutor will result in errors. To resolve this, relocate such classes to an importable .py file.

>>> from concurrent.futures import ProcessPoolExecutor
>>> job.server.executor = ProcessPoolExecutor()
>>> job.server.future.done()
False
>>> job.server.future.result()
>>> job.server.future.done()
True
Parameters:
  • job (GenericJob) – pyiron job object

  • executor (concurrent.futures.Executor) – executor class which implements the executor interface defined in the python concurrent.futures.Executor class.