'"A process in the process pool was terminated abruptly" error on concurrent.futures.ProcessPoolExecutor()
I'm trying to multiply matrices using multiprocessing to see how much faster it can run than a regular synchronous process. Here is the function:
def multvecs(inp):
vec1, vec2, index = inp
#i, j = index
sum = 0
for k in range(vec1.shape[0]):
sum += vec1[k] * vec2[k]
#prod[i][j] = sum
return sum, index
def asyncmult(m1, m2):
threads = []
prod = np.zeros((m1.shape[0], m2.shape[1]))
with concurrent.futures.ProcessPoolExecutor() as executor:
for i in range(m1.shape[0]):
for j in range(m2.shape[1]):
f = executor.submit(multvecs, (m1[i], m2[:, j], (i, j)))
threads.append(f)
for f in concurrent.futures.as_completed(threads):
vprod, index = f.result()
i, j = index
prod[i][j] = vprod
return prod
I'm running this on windows so I protected the entire main with if name == 'main'.
concurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending
This is the error message. how do I fix this? I tried saving the file as well as moving multvecs() to outermost scope.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
