- #1
fred_91
- 39
- 0
Homework Statement
I have the following code (please see below). I want it to return [2,4,6,8,10] which is the function evaluated at the given list [1,2,3,4,5]. I want to do this using the process command.
My problem is:
print A returns
[None, None, None, None, None]
But I want it to return
[2,4,6,8,10]
Many thanks in advance.
Homework Equations
The Attempt at a Solution
import multiprocessing as mp
from multiprocessing import Process
def func(x):
y = x*2
print y
return y
def OutFunc(f1,a):
if __name__ == '__main__':
OutputList = []
res = []
for I in range(5):
p=mp.Process(target=f1, args = (a,))
OutputList.append(p)
p.start()
for proc in OutputList:
result = proc.join()
res.append(result)
return res
A = OutFunc(func,[1,2,3,4,5])
print A