From 2f265bd0e447bc37235b20db2b545bdafd0843da Mon Sep 17 00:00:00 2001 From: Jonathan Karlsen Date: Wed, 4 Dec 2024 14:07:30 +0100 Subject: [PATCH] Fix ForwardModelStep `handle_process_timeout...` timeout This fixes the bug where some code was unreachable after the refactoring in commit #4dc894ca63687476e091f582df5a42045190f7bd --- src/_ert/forward_model_runner/forward_model_step.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/_ert/forward_model_runner/forward_model_step.py b/src/_ert/forward_model_runner/forward_model_step.py index 8f84b944ee6..b38f90d9b0f 100644 --- a/src/_ert/forward_model_runner/forward_model_step.py +++ b/src/_ert/forward_model_runner/forward_model_step.py @@ -175,7 +175,7 @@ def _run(self) -> Generator[Start | Exited | Running | None]: target_file = self.job_data.get("target_file") target_file_mtime: Optional[int] = _get_target_file_ntime(target_file) - + run_start_time = dt.now() try: proc = Popen( arg_list, @@ -217,7 +217,9 @@ 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(exit_code, proc) + self.handle_process_timeout_and_create_exited_msg( + exit_code, proc, run_start_time + ) ) if isinstance(potential_exited_msg, Exited): yield potential_exited_msg @@ -281,13 +283,12 @@ def _create_exited_msg_for_non_zero_exit_code( ) def handle_process_timeout_and_create_exited_msg( - self, exit_code: Optional[int], proc: Popen[Process] + self, exit_code: Optional[int], proc: Popen[Process], run_start_time: dt ) -> Exited | None: max_running_minutes = self.job_data.get("max_running_minutes") - run_start_time = dt.now() run_time = dt.now() - run_start_time - if max_running_minutes is None or run_time.seconds > max_running_minutes * 60: + if max_running_minutes is None or run_time.seconds < max_running_minutes * 60: return None # If the spawned process is not in the same process group as