From 3d44ae0d96ab9f57d0dc29c6486af5fff372d9e7 Mon Sep 17 00:00:00 2001 From: Andreas Plach <andreas.plach@univie.ac.at> Date: Mon, 19 Oct 2020 17:46:09 +0200 Subject: [PATCH] alp: tools.py - simplified check for active jobs --- Source/Python/Mods/tools.py | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/Source/Python/Mods/tools.py b/Source/Python/Mods/tools.py index fb6585e..d0274c5 100644 --- a/Source/Python/Mods/tools.py +++ b/Source/Python/Mods/tools.py @@ -727,30 +727,14 @@ def submit_job_to_ecserver(target, jobname): noWAIT = 99 waittime = 10 - while noEXEC>10: - # run "ecaccess-job-list | grep EXEC" and split the resulting - # string at the whitespaces and then count the number of - # occurences of EXEC => # of active jobs - ps = subprocess.Popen(('ecaccess-job-list'), stdout=subprocess.PIPE) - try: - output = str(subprocess.check_output(('grep', 'EXEC'), stdin=ps.stdout)).split() - except subprocess.CalledProcessError: - break - noEXEC = output.count('EXEC') - print('number of active jobs: ', str(noEXEC)) - import time - print('waiting until less processes are active (checking every '+str(waittime)+'s)') - time.sleep(waittime) - - # do the same for waiting jobs - while noWAIT>5: - ps = subprocess.Popen(('ecaccess-job-list'), stdout=subprocess.PIPE) - try: - output = str(subprocess.check_output(('grep', 'WAIT'), stdin=ps.stdout)).split() - except subprocess.CalledProcessError: - break - noWAIT = output.count('WAIT') - print('number of waiting jobs: ', str(noWAIT)) + while (noEXEC+noWAIT)>12: + # do "ecaccess-job-list" and check the numbers of EXEC and + # WAIT => # of active jobs + ps = subprocess.check_output(('ecaccess-job-list')) + noEXEC = str(ps).count('EXEC') + noWAIT = str(ps).count('WAIT') + print('number of EXEC jobs: ', str(noEXEC)) + print('number of WAIT jobs: ', str(noWAIT)) import time print('waiting until less processes are active (checking every '+str(waittime)+'s)') time.sleep(waittime) -- GitLab