How can I run multiple python files at the same time? There are 3 files: bot_1.py, bot_2.py, bot_3.py. I would like to run them at the same time. I attached the code. What should I write in the worker function to make this script work? I will appreciate any help.
import multiprocessing
import subprocess
def worker(file):
#your subprocess code
subprocess.Popen(['screen', './bot_1.py'])
subprocess.Popen(['screen', './bot_2.py'])
subprocess.Popen(['screen', './bot_3.py'])
if __name__ == '__main__':
files = ["bot_1.py","bot_2.py","bot_3.py"]
for i in files:
p = multiprocessing.Process(target=worker(i))
p.start()