I have a function that takes several arguments, some of which are logical. I am trying to pass this to multiprocessing pool.apply_async and want to pass some arguments with attached names.
Here is an example script I'm working with:
from multiprocessing import Pool def testFunc(y, x, calcY=True): if calcY == True: return y*y elif calcY == False: return x*x if __name__ == "__main__": p = Pool() res = p.apply_async(testFunc, args = (2, 4, False)) print res.get()
This works, but I'm interested in changing res = p.apply_async(testFunc, args = (2, 4, False)) to something like:
res = p.apply_async(testFunc, args = (2, 4, calcY = False))
source share