Reputation: 1323
I am trying to run multiple python scripts in parallel with subprocess
in a linux OS
Similar to this: Running multiple commands from multiple terminal windows from python script
Here is what I tried:
subprocess.call(['gnome-terminal', '-e', "python3 ab.py"])
subprocess.call(['gnome-terminal', '-e', "python3 bc.py"])
subprocess.call(['gnome-terminal', '-e', "python3 cd.py"])
Unfortunately, the terminal flashes in split seconds and disappears. Any reason for this? adding shell=True
makes the terminal stays but does not execute the script.
Upvotes: 0
Views: 1193
Reputation: 39354
Do you need to split all parts of the command line into separate strings?
subprocess.call(['gnome-terminal', '-e', "python3", "ab.py"])
Upvotes: 0
Reputation: 71570
subprocess.run
should work:
subprocess.Popen(['gnome-terminal', '-e', "python3", "ab.py"], shell=True)
subprocess.Popen(['gnome-terminal', '-e', "python3", "bc.py"], shell=True)
subprocess.Popen(['gnome-terminal', '-e', "python3", "cd.py"], shell=True)
Edit:
os.system("gnome-terminal -x python ab.py")
Upvotes: 3