1

I've been doing a loop to call subprocesses from a list of commands:

commands=[
    'do a',
    'do b']
for cmd in commands:
    process = subprocess.run(cmd, shell=True, check=True)
    if (process.returncode != 0): 
        raise RuntimeError(f'Lustre configuration failed: {cmd} returned non-zero exit status {process.returncode}\n STDERR: {process.stderr.decode("utf-8")}')

It lets me know if my script failed, and where it did

When I was launching all the commands with a ";".join(commands) directly in a subprocess it was working fine, but now that I do it in a loop it exits or kill a process in the list randomly

Is there a logic behind this behaviour? subprocess.run is supposed to be synchronous so I shouldn't get this kind of error

PS: the commands more precisely are for mounting a filesystem through sgdisk / partprobe / mkfs and mount

I tried running all the commands together joining them with ";" or " && " Using other blocking functions of subprocess Nothing worked out

Exania
  • 96
  • 3

0 Answers0