Whenever I run subprocess.run({file location}) my whole script hangs until I have closed the windows app that I opened with subprocess.run({file location}). The exception doesn't catch it, what should I do?
My code looks like this
def open_app(location):
try:
subprocess.run(location)
except subprocess.SubprocessError as error:
print(error)
1 Answer 1
subprocess.run specifically waits for the process to finish before continuing with the rest of your script. If you want to run it in the background use subprocess.Popen
answered Sep 11, 2021 at 20:12
BTables
4,9002 gold badges14 silver badges35 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Explore related questions
See similar questions with these tags.
lang-py
locationdo?subprocess.run("C:\{path}\Spotify.exe")will open spotify. @BTables