Nicke7117
Nicke7117

Reputation: 197

Python: script hangs at subprocess.run()

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)

Upvotes: 1

Views: 1840

Answers (1)

BTables
BTables

Reputation: 4843

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

Upvotes: 1

Related Questions