1

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)
asked Sep 11, 2021 at 20:08
2
  • What exactly does the file at location do? Commented Sep 11, 2021 at 20:09
  • It means the .exe file location, so for example subprocess.run("C:\{path}\Spotify.exe") will open spotify. @BTables Commented Sep 11, 2021 at 20:11

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.