简体   繁体   中英

Run python in background from other python program and continue

How to run a python program in between another python program

os.system(r'pythonw.exe D:\text.py')

I have tried this but it had pause execution between the main program and also tried

subprocess.run(r'pythonw.exe D:\text.py')

suppose I have program text.py which notify me every hour I have main program ie

code...
os.system(r'pythonw.exe D:\text.py')
code...
print("hello world")

my command should run text.py in the background and execute the following code.

You can use Python Library named "Soldier". This is very easy to use and implement. https://pypi.org/project/soldier

import soldier

firefox_process = soldier.run('firefox', background=True)
firefox_process.pid

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM