Here is my code:
from math import sqrt
from joblib import Parallel, delayed
import multiprocessing
def parallel_calc():
if __name__ == '__main__':
result = Parallel(n_jobs=2)(delayed(sqrt)(i ** 2) for i in range(10))
return result
result = parallel_calc()
print(result[-1])
It generates error message: print(result[-1]) TypeError: 'NoneType' object is not subscriptable
. In addition, it does not terminate.
Since I am on Window 7, I have to use this check if __name__ == '__main__':
, but how do I get result from parallel_calc
function?