How to use multiprocessing pool.map with multiple arguments?

前端 未结 20 3469
-上瘾入骨i
-上瘾入骨i 2020-11-21 11:24

In the Python multiprocessing library, is there a variant of pool.map which supports multiple arguments?

text = "test"
def         


        
20条回答
  •  遇见更好的自我
    2020-11-21 11:50

    for python2, you can use this trick

    def fun(a,b):
        return a+b
    
    pool = multiprocessing.Pool(processes=6)
    b=233
    pool.map(lambda x:fun(x,b),range(1000))
    

提交回复
热议问题