From 307c62c85c2eada4a1be7c93ea4130294874685d Mon Sep 17 00:00:00 2001 From: vsc46128 vscuser Date: Thu, 22 Feb 2024 13:09:12 +0100 Subject: [PATCH] move poll_interval and skip loop if job_manager.get_current_jobs() fails --- eessi_bot_job_manager.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/eessi_bot_job_manager.py b/eessi_bot_job_manager.py index ebb00fd6..288b8014 100644 --- a/eessi_bot_job_manager.py +++ b/eessi_bot_job_manager.py @@ -674,6 +674,13 @@ def main(): if max_iter != 0: known_jobs = job_manager.get_known_jobs() while max_iter < 0 or i < max_iter: + # sleep poll_interval seconds (not for the first iteration) + if i != 0 and (max_iter < 0 or i < max_iter): + log( + "job manager main loop: sleep %d seconds" % poll_interval, + job_manager.logfile, + ) + time.sleep(poll_interval) log("job manager main loop: iteration %d" % i, job_manager.logfile) log( "job manager main loop: known_jobs='%s'" % ",".join( @@ -681,7 +688,12 @@ def main(): job_manager.logfile, ) - current_jobs = job_manager.get_current_jobs() + try: + current_jobs = job_manager.get_current_jobs() + except: + i = i + 1 + continue + log( "job manager main loop: current_jobs='%s'" % ",".join( current_jobs.keys()), @@ -736,13 +748,7 @@ def main(): known_jobs = current_jobs - # sleep poll_interval seconds (only if at least one more iteration) - if max_iter < 0 or i + 1 < max_iter: - log( - "job manager main loop: sleep %d seconds" % poll_interval, - job_manager.logfile, - ) - time.sleep(poll_interval) + # add one iteration to the loop i = i + 1