Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ForwardModelStep handle_process_timeout... timeout #9446

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need some explanation what this function actually does?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It handles how we should react on a timeout while polling the process status. If it returns Exited, we yield it and return, otherwise we try again.
It should fail if the running_time goes above what is configured for the forward_model, but we currently reset the running time every time we timeout, so it never reaches this code path.
The timeout function should kill the entire process group if it is different than its own process group, then return an exited message with an error attached.

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
Loading