import os
import sys
command_0 = './main'
command_1 = './main'
os.system(command_0)
os.system(command_1)
I want to run a script called 'main' twice simultaneously using python, the problem is that command_0 run for 5 seconds and only when it finishes the command_1 is called. Is it possible to run both simultaneously?
you have 2 options:
os.system(command &)
use queue / subprocess:
def worker(): while True: item = q.get() os.system(item) q = Queue() for i in tasks: t = Thread(target=worker) t.setDaemon(True) t.start() for item in tasks: q.put(item) q.join()
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.