I have a function in python with arguments.Within the same file I call that function(call it foo). Is there any way in python(for Win7) that I can create different independent processes from the parent process with each process executing foo with different set of arguments(obviously independent from the parent process as well)? Can a console be also attached to these process?
PS: I know that if it is a separate script or exe then we can use Popen.subprocess() module. But here the problem is of assigning a function(code) to different process(independent from each other as well as of the parent).
This is the function.
import subprocess
import os
import string
def add(x,y):
return x+y
This is the input file:
1 2
3 4
5 6
Now if function were written in some separate file(add.py) we can directly use subprocess.Popen() to call "add.py" for each set of arguments from the input file. But if the function is written in the same file as the main file then how to assign a new process to each set of arguments from the input file shown? I can't use fork() because there isn't any for Windows.