Created
March 11, 2015 06:30
-
-
Save meren/dbdef7adc18ea1b34048 to your computer and use it in GitHub Desktop.
Don't move to the next line in a batch operation until all jobs are done on the cluster, or, "poor man's hold"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import time | |
import xml.dom.minidom | |
import string | |
import getpass | |
def still_running(job_name, job_owner): | |
f=os.popen('qstat -u \* -xml -r') | |
dom=xml.dom.minidom.parse(f) | |
jobs = dom.getElementsByTagName('job_info') | |
run = jobs[0] | |
joblist = run.getElementsByTagName('job_list') | |
for r in joblist: | |
job = r.getElementsByTagName('JB_name')[0].childNodes[0].data | |
owner = r.getElementsByTagName('JB_owner')[0].childNodes[0].data | |
if job == job_name and owner == job_owner: | |
return True | |
return False | |
job_owner = getpass.getuser() | |
job_name = sys.argv[1] | |
counter = 0 | |
while still_running(job_name, job_owner): | |
time.sleep(5) | |
counter += 1 | |
if counter == 11: | |
sys.stderr.write('.') | |
counter = 0 | |
sys.stderr.write('\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment