I'm trying to build a script that opens all of the web dev programs I use. I want the print("Opened all apps")
to only run once all 3 programs have opened and fully loaded (rather than currently printing after just opening the programs and not waiting for them to load) because I want to do something after they've loaded.
I have the following:
import subprocess
chrome = "Google Chrome"
mongo = "MongoDB Compass"
vsc = "Visual Studio Code"
apps = [chrome, vsc, mongo]
for app in apps:
p = subprocess.Popen(["open", "-a", app])
print("Opening " + app)
p.wait()
print("Opened?")
print("Opened all apps")
However, the problem is that p.wait()
seems to not wait for each app to load. Does anyone know why this happens and how to make it wait properly for all apps to fully load?
I tried the suggestions from this post: Python: waiting for external launched process finish
Thank you for any advice