From 7074b1fca6ce928d3e131d5300e9d4dd708e2262 Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Thu, 22 Jun 2023 01:34:58 +0200 Subject: [PATCH 1/2] Raise job timeout error in local scheduler --- reframe/core/schedulers/local.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/reframe/core/schedulers/local.py b/reframe/core/schedulers/local.py index 2105e45a7f..67cada2fde 100644 --- a/reframe/core/schedulers/local.py +++ b/reframe/core/schedulers/local.py @@ -12,7 +12,7 @@ import reframe.core.schedulers as sched import reframe.utility.osext as osext from reframe.core.backends import register_scheduler -from reframe.core.exceptions import ReframeError +from reframe.core.exceptions import JobError, ReframeError class _TimeoutExpired(ReframeError): @@ -187,9 +187,12 @@ def _poll_job(self, job): # Job has not finished; check if we have reached a timeout t_elapsed = time.time() - job.submit_time if job.time_limit and t_elapsed > job.time_limit: - self.log(f'Job {job.jobid} timed out; kill it') self._kill_all(job) job._state = 'TIMEOUT' + job._exception = JobError( + f'job timed out ({t_elapsed:.2f}s > {job.time_limit}s)', + job.jobid + ) return From 3a85fb5a672a775e8fe8d8143551fe1e31d9949d Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Thu, 22 Jun 2023 01:46:17 +0200 Subject: [PATCH 2/2] Fix unit tests --- reframe/core/schedulers/local.py | 2 +- unittests/test_schedulers.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/reframe/core/schedulers/local.py b/reframe/core/schedulers/local.py index 67cada2fde..5ace2c917a 100644 --- a/reframe/core/schedulers/local.py +++ b/reframe/core/schedulers/local.py @@ -190,7 +190,7 @@ def _poll_job(self, job): self._kill_all(job) job._state = 'TIMEOUT' job._exception = JobError( - f'job timed out ({t_elapsed:.2f}s > {job.time_limit}s)', + f'job timed out ({t_elapsed:.6f}s > {job.time_limit}s)', job.jobid ) diff --git a/unittests/test_schedulers.py b/unittests/test_schedulers.py index 545c6d2033..797fecd2b2 100644 --- a/unittests/test_schedulers.py +++ b/unittests/test_schedulers.py @@ -487,7 +487,9 @@ def test_submit_timelimit(minimal_job, local_only): t_job = time.time() submit_job(minimal_job) assert minimal_job.jobid is not None - minimal_job.wait() + with pytest.raises(JobError): + minimal_job.wait() + t_job = time.time() - t_job assert t_job >= 2 assert t_job < 3