1

Using python 2.7, windows 7 64 bit. I want to call external application to get launch using python script. And after launching external application, the main process should continue and finally terminate without ever waiting or listening for external application to terminate. Means, as external application is launched, main process should not depend on external application for termination. I used:

print "ss"
os.system(r"D:\pythonCode\external.exe")
print "application started"

In above,code, external.exe is launched, but it never prints "application started", and main process so never terminates.

Also tried with:

p = subprocess.Popen([r"D:\pythonCode\external.exe"])
print "application started"
sys.exit(0)

In above case, external.exe is launched, it prints "application started", but main process never terminates. Main process waits for external application to terminates, which is not desired. I also looked into this q&a but not get solution for it.

I also tried with p=subprocess.Popen([r"D:\pythonCode\external.exe"],creationflags=subprocess.CREATE_NEW_PROCESS_GROUP), but same blocking happens

and also

DETACHED_PROCESS = 0x00000008
pid = subprocess.Popen([r"D:\pythonCode\external.exe"], creationflags=DETACHED_PROCESS).pid
7
  • duplicated! stackoverflow.com/a/16928558/1093020 Commented Mar 13, 2014 at 7:20
  • @Leonardo.Z The answer is for unix system, I am asking for windows HERE Commented Mar 13, 2014 at 7:29
  • read the answer again! Commented Mar 13, 2014 at 7:30
  • @Leonardo.Z preexec_fn=os.setpgrp is nor unix, can you comment here the answer you are talking about Commented Mar 13, 2014 at 7:42
  • 1
    try os.startfile(). Or start_new_session analog Commented Mar 13, 2014 at 11:57

0

Your Answer

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.