I\'ve researched this question multiple times, but haven\'t found a workaround that either works in my case, or one that I understand, so please bear with me.
Basically
How about just taking the embedded function out?
This seems to me the clearest solution (since you didn't give your expected output, I had to guess):
$ cat /tmp/tmp.py
import multiprocessing
def calculate(x):
# here is where I would take this input x (and maybe a couple more inputs)
# and build a larger library of variables that I use further down the line
pool = multiprocessing.Pool(3)
_lst = [(x, y) for x in (x,) for y in range(3)]
final= pool.map(domath, _lst)
print(final)
def domath(l):
return l[0] * l[1]
calculate(2)
$ python /tmp/tmp.py
[0, 2, 4]
$