Commit b5be1476 authored by Michael Salim's avatar Michael Salim
Browse files

Popen explicitly uses bash shell; "time" command did not work with sh

parent b063056f
......@@ -21,3 +21,4 @@ docs/_static/*
*.egg-info
default_balsamdb
testdb
......@@ -27,6 +27,10 @@ def resolve_db_path(path=None):
assert os.path.exists(path), f"balsamDB path {path} not found"
else:
path = default_db_path
path = os.path.expanduser(path)
path = os.path.abspath(path)
os.environ['BALSAM_DB_PATH'] = path
return path
def configure_db_backend(db_path):
......
......@@ -93,7 +93,8 @@ def run(job):
cmd = f"time -p ( {job.cmd} )"
env = job_from_db.get_envs() # TODO: Should we include this?
proc = Popen(cmd, stdout=outf, stderr=STDOUT,
cwd=job.workdir,env=env, shell=True)
cwd=job.workdir,env=env, shell=True,
executable='/bin/bash')
handler = lambda a,b: on_exit(proc)
signal.signal(signal.SIGINT, handler)
......
......@@ -160,6 +160,7 @@ class MPIRunner(Runner):
self.popen_args['stdout'] = self.outfile
self.popen_args['stderr'] = STDOUT
self.popen_args['shell'] = True
self.popen_args['executable'] = '/bin/bash'
self.popen_args['bufsize'] = 1
logger.info(f"MPIRunner {job.cute_id} Popen:\n{self.popen_args['args']}")
logger.info(f"MPIRunner: writing output to {outname}")
......
......@@ -8,7 +8,8 @@ def time_cmd(cmd, stdout=PIPE, stderr=STDOUT, envs=None):
cmd = f'time ( {cmd} )'
p = subprocess.Popen(cmd, shell=True, stdout=stdout,
stderr=stdout, env=envs)
stderr=stdout, env=envs,
executable='/bin/bash')
stdout = p.communicate()[0].decode('utf-8')
real_seconds = parse_real_time(stdout)
return stdout, realtime
......
......@@ -78,7 +78,8 @@ def cmdline(cmd,envs=None):
cmd = f'time -p ( {cmd} )'
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,env=envs)
stderr=subprocess.STDOUT,env=envs,
executable='/bin/bash')
stdout = p.communicate()[0].decode('utf-8')
realtime = get_real_time(stdout)
return stdout, realtime
......
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