Commit 0dbbaaf6 authored by Peter-Bernd Otte's avatar Peter-Bernd Otte

Improve speed on worker, changed to subprocess.run call for ranks>0

parent 91115df0
...@@ -251,22 +251,23 @@ while True: ...@@ -251,22 +251,23 @@ while True:
bashCommand = workstr + " > " + outputdir + str(jobid) + "/std_out.txt 2> " + outputdir + str(jobid) + "/err_out.txt" bashCommand = workstr + " > " + outputdir + str(jobid) + "/std_out.txt 2> " + outputdir + str(jobid) + "/err_out.txt"
try: try:
p = subprocess.Popen(bashCommand, shell=True) if rank == 0:
logger.info('Worker startet job.') p = subprocess.Popen(bashCommand, shell=True) # start job in background
logger.info('Worker startet job.')
else:
completed = subprocess.run(bashCommand, shell=True) # start job and wait for return
logger.info('Job ended, return code: '+str(completed.returncode) )
except subprocess.CalledProcessError as err: except subprocess.CalledProcessError as err:
logger.info('Worker ' + str(rank) + ' ERROR:', err) logger.info('Worker ' + str(rank) + ' ERROR:', err)
WorkerFSM = 3 WorkerFSM = (3 if rank == 0 else 0)
if WorkerFSM == 3: #State 3: Running if WorkerFSM == 3: #State 3: Running, used only for rank = 0 with subprocess.Popen
if p.poll() is not None: if p.poll() is not None:
logger.info("Job ended, ret code: " + str(p.returncode)) logger.info("Job ended, return code: " + str(p.returncode))
WorkerFSM = 0 WorkerFSM = 0
if rank == 0: time.sleep(0.01) # to take some load off the node
time.sleep(0.01) # to take some load off the node
else:
time.sleep(1)
logger.info("Worker ended.") logger.info("Worker ended.")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment