From e4017543bdf176eee2747e28b21f5ae92777509a Mon Sep 17 00:00:00 2001 From: Jonathan Karlsen Date: Fri, 4 Oct 2024 07:40:40 +0200 Subject: [PATCH] debug commit --- src/_ert/forward_model_runner/job.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/_ert/forward_model_runner/job.py b/src/_ert/forward_model_runner/job.py index 3deb21101b9..9d422b70df7 100644 --- a/src/_ert/forward_model_runner/job.py +++ b/src/_ert/forward_model_runner/job.py @@ -177,8 +177,8 @@ def _run(self) -> Generator[Start | Exited | Running | None]: exited_message = self._handle_process_io_error_and_create_exited_message( e, stderr ) - ensure_file_handles_closed([stdin, stdout, stderr]) yield exited_message + ensure_file_handles_closed([stdin, stdout, stderr]) return exit_code = None @@ -204,21 +204,20 @@ def _run(self) -> Generator[Start | Exited | Running | None]: exit_code = process.wait(timeout=self.MEMORY_POLL_PERIOD) except TimeoutExpired: potential_exited_msg = ( - self.handle_process_timeout_and_create_exited_msg(process, proc) + self.handle_process_timeout_and_create_exited_msg(exit_code, proc) ) - fm_step_pids |= { - int(child.pid) for child in process.children(recursive=True) - } if isinstance(potential_exited_msg, Exited): yield potential_exited_msg return + fm_step_pids |= { + int(child.pid) for child in process.children(recursive=True) + } ensure_file_handles_closed([stdin, stdout, stderr]) exited_message = self._create_exited_message_based_on_exit_code( max_memory_usage, target_file_mtime, exit_code, fm_step_pids ) - assert exited_message.job yield exited_message def _create_exited_message_based_on_exit_code( @@ -247,7 +246,7 @@ def _create_exited_message_based_on_exit_code( if target_file_error: return exited_message.with_error(target_file_error) - return Exited(self, exit_code) + return exited_message def _create_exited_msg_for_non_zero_exit_code( self, @@ -271,7 +270,7 @@ def _create_exited_msg_for_non_zero_exit_code( ) def handle_process_timeout_and_create_exited_msg( - self, process: Process, proc: Popen[Process] + self, exit_code: Optional[int], proc: Popen[Process] ) -> Exited | None: max_running_minutes = self.job_data.get("max_running_minutes") run_start_time = dt.now() @@ -291,7 +290,7 @@ def handle_process_timeout_and_create_exited_msg( if process_group_id != this_group_id: os.killpg(process_group_id, signal.SIGKILL) - return Exited(self, proc.returncode).with_error( + return Exited(self, exit_code).with_error( ( f"Job:{self.name()} has been running " f"for more than {max_running_minutes} "