Skip to content

Commit

Permalink
Fix ForwardModelStep handle_process_timeout... timeout
Browse files Browse the repository at this point in the history
This fixes the bug where some code was unreachable after the refactoring in commit #4dc894ca63687476e091f582df5a42045190f7bd
  • Loading branch information
jonathan-eq committed Dec 10, 2024
1 parent 8e00339 commit bf2d515
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/_ert/forward_model_runner/forward_model_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bf2d515

Please sign in to comment.