Execute Multiple .py Files At The Same Time
I have three .py files that I want to run at the same time in a Python script file. I initially called subprocess.call() three times (once for each .py file) but remembered that it
Solution 1:
If you want to use multiprocessing
, you can try this:
import multiprocessing
def worker(file):
# your subprocess code
if __name__ == '__main__':
files = ["path/to/file1.py","path/to/file2.py","path/to/file3.py"]
for i in files:
p = multiprocessing.Process(target=worker, args=(i,))
p.start()
Post a Comment for "Execute Multiple .py Files At The Same Time"