1

The problem I need to solve is how to launch a program from python3 in such a way that control is passed back to the python script to do other things. I have experimented with os.system and subprocess.call as so

import subprocess, os
os.system('gedit&')
subprocess.call(['gedit','&'])

both of which seem to wait for gedit, in a sence like it is waiting on some sort of stream from gedit. If I type gedit & at the terminal I get the desired effect outside of python.

asked Jun 9, 2014 at 6:09

1 Answer 1

1

Use subprocess.Popen:

subprocess.Popen(['gedit'])

subprocess.call essentially does the above line, but then calls communicate on the resulting object, which waits for it to exit. Since you don't want to wait, you can just not call communicate, and the process will be created, leaving your process to go on its merry way.

answered Jun 9, 2014 at 6:13
Sign up to request clarification or add additional context in comments.

1 Comment

This was the solution I was looking for, Thank you. I should have done more research into subprocess. My apologies. Your help was greatly apreciated.

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.