Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
Add callback function for catching MAX_RUNTIME failure
Browse files Browse the repository at this point in the history
Co-authored-by: Morten Bendiksen <[email protected]>
  • Loading branch information
kvashchuka and mortalisk committed May 20, 2021
1 parent 685467b commit f3ade4d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions python/res/job_queue/job_queue_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ def __init__(
exit_callback_function,
callback_arguments,
max_runtime=None,
callback_timeout=None,
):
self.done_callback_function = done_callback_function
self.exit_callback_function = exit_callback_function
self.callback_timeout = callback_timeout
self.callback_arguments = callback_arguments
argc = 1
argv = StringList()
Expand Down Expand Up @@ -159,6 +161,12 @@ def _job_monitor(self, driver, pool_sema, max_submit):
self.update_status(driver)
if self._should_be_killed():
self._kill(driver)
if (
self._max_runtime
and self.runtime >= self._max_runtime
and self.callback_timeout
):
self.callback_timeout(self.callback_arguments)

self._end_time = time.time()

Expand Down
3 changes: 2 additions & 1 deletion python/res/job_queue/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ def add_job_from_run_arg(self, run_arg, res_config, max_runtime, ok_cb, exit_cb)
return
run_arg._set_queue_index(self.add_job(job, run_arg.iens))

def add_ee_stage(self, stage):
def add_ee_stage(self, stage, callback_timeout):
job = JobQueueNode(
job_script=stage.get_job_script(),
job_name=stage.get_job_name(),
Expand All @@ -519,6 +519,7 @@ def add_ee_stage(self, stage):
exit_callback_function=stage.get_exit_callback(),
callback_arguments=stage.get_callback_arguments(),
max_runtime=stage.get_max_runtime(),
callback_timeout=callback_timeout,
)
if job is None:
raise ValueError("JobQueueNode constructor created None job")
Expand Down

0 comments on commit f3ade4d

Please sign in to comment.