Skip to content

Commit

Permalink
debug commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-eq committed Oct 4, 2024
1 parent 7049ec0 commit e401754
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/_ert/forward_model_runner/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand All @@ -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()
Expand All @@ -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} "
Expand Down

0 comments on commit e401754

Please sign in to comment.