I am trying to run 'test.py' python program from another python program which accepts system argument every time in a for loop. As test.py needs to run always so using subprocess to start it. But the test.py starts only one time and the loop waits for it to finish to start another.
I am to continue and start another.
import subprocess
if __name__ == '__main__':
someList = ['a', 'b', 'c']
for index in someList:
command = 'python test.py ' + index
print(command)
pipe = subprocess.Popen(command, shell = True, stdout = subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = pipe.communicate()
Code for test.py might look something like this
import sys
if __name__ == '__main__':
someArg = str(sys.argv[1])
while(True):
#code that uses sys.argv and runs for infinite time