Skip to content

Commit

Permalink
Serialize/block on so-called background call
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolphpienaar committed Aug 15, 2022
1 parent 0c6dc4c commit 0f308d5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pfdcm/controllers/jobController.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ def job_run(self, str_cmd: str):
"""
Running some CLI process via python is cumbersome. The typical/easy
path of
os.system(str_cmd)
is deprecated and prone to hidden complexity. The preferred
method is via subprocess, which has a cumbersome processing
syntax. Still, this method runs the `str_cmd` and returns the
Expand Down Expand Up @@ -140,23 +142,21 @@ def job_runbg(self, str_cmd : str) -> dict:
'cmd' : "",
'cwd' : ""
}
# str_stdoutLine : str = ""
# str_stdout : str = ""

p = subprocess.Popen(
process = subprocess.Popen(
str_cmd.split(),
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
close_fds = True
)

for line in process.stdout:
pass
process.wait()

d_ret['uid'] = str(os.getuid())
d_ret['cmd'] = str_cmd
d_ret['cwd'] = os.getcwd()
# d_ret['stdout'] = str_stdout
# d_ret['stderr'] = p.stderr.read().decode()
# d_ret['returncode'] = p.returncode
# if int(self.args['verbosity']) and len(d_ret['stderr']):
# print('\nstderr: \n%s' % d_ret['stderr'])
return d_ret

def job_stdwrite(self, d_job : dict, str_outputDir : str, str_prefix : str = "") -> dict:
Expand Down

0 comments on commit 0f308d5

Please sign in to comment.