I have a python script in which i run two commands using subProcess. I want these commands to run in parallel. When i run the python script on my machine these commands do run in parallel but when i run the script via Jenkins it runs them one after the other. How can i run these command in parallel in jenkins?
reg_path = os.environ['PWD']
command1 = f'python3 {python_script_path} {reg_path} '
command2 = f'python3 {python_script_path} {reg_path} '
processes = []
for i in range(1):
f = subprocess.Popen(command2, shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p = subprocess.Popen(command1, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
processes.append((p, f))
p.wait()
out, err = p.communicate()
fout, ferr = f.communicate()
p.kill()
f.kill()
errMsg = 'other processes are running'
assert errMsg in str(fout) or errMsg in str(out)
Thanks