I want to know if there is any way to call a python script and just completely start that programe in a different thread so the main programe (caller) does not have to wait till the called script finishes executing. So far I've tried subprocess, and os.system but both of these two lag on until the script finishes executing.
os.system('"F:\second.py"')
//continue the rest of the code without waiting for second.py to finish
//do stuff
you can try subprocess
first.py
import subprocess
subprocess.Popen(["python.exe", "second.py"])
print "done"
second.py
import time
for i in range(10):
print i
time.sleep(10)
EDIT:
if you want to completly seperate the first and the second script add a flag
first.py
import subprocess
subprocess.Popen(["python.exe", "second.py"], creationflags=subprocess.CREATE_NEW_CONSOLE)
print "done"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With