使用线程和子进程模块同时运行多个python脚本
import threading
import subprocess
import sys
import time
def run_process(path):
cmd = 'python %s' % path
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
for line in iter(process.stdout.readline, ''):
sys.stdout.write(line)
t1 = threading.Thread(target=run_process, args=('script1.py',))
t2 = threading.Thread(target=run_process, args=('script2.py',))
t3 = threading.Thread(target=run_process, args=('script3.py',))
t4 = threading.Thread(target=run_process, args=('script4.py',))
t5 = threading.Thread(target=run_process, args=('script5.py',))
#start
t1.start()
t2.start()
t3.start()
t4.start()
t5.start()
# Waiting
t1.join()
t2.join()
t3.join()
t4.join()
t5.join()
如何使用pyinstaller创建一个运行5个python脚本的exe文件?