diff --git a/pyiron_base/jobs/datamining.py b/pyiron_base/jobs/datamining.py index 8a1eca65c..d0081733a 100644 --- a/pyiron_base/jobs/datamining.py +++ b/pyiron_base/jobs/datamining.py @@ -792,12 +792,13 @@ def update_table(self, job_status_list=None): if self._executor_type is None and self.server.cores > 1: self._executor_type = "pympipool.mpi.executor.PyMPIExecutor" if self._executor_type is not None: - self._pyiron_table.create_table( - file=hdf5_input, - job_status_list=job_status_list, - enforce_update=self._enforce_update, - executor=self._get_executor(max_workers=self.server.cores), - ) + with self._get_executor(max_workers=self.server.cores) as exe: + self._pyiron_table.create_table( + file=hdf5_input, + job_status_list=job_status_list, + enforce_update=self._enforce_update, + executor=exe, + ) else: self._pyiron_table.create_table( file=hdf5_input, diff --git a/pyiron_base/jobs/flex/pythonfunctioncontainer.py b/pyiron_base/jobs/flex/pythonfunctioncontainer.py index 1ad542c92..b7301f06f 100644 --- a/pyiron_base/jobs/flex/pythonfunctioncontainer.py +++ b/pyiron_base/jobs/flex/pythonfunctioncontainer.py @@ -102,9 +102,8 @@ def run_static(self): ): input_dict = self.input.to_builtin() del input_dict["executor"] - output = self._function( - **input_dict, executor=self._get_executor(max_workers=self.server.cores) - ) + with self._get_executor(max_workers=self.server.cores) as exe: + output = self._function(**input_dict, executor=exe) else: output = self._function(**self.input.to_builtin()) self.output.update({"result": output})