How to use multiprocessing pool.map with multiple arguments?

前端 未结 20 3968
-上瘾入骨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:52

    How to take multiple arguments:

    def f1(args):
        a, b, c = args[0] , args[1] , args[2]
        return a+b+c
    
    if __name__ == "__main__":
        import multiprocessing
        pool = multiprocessing.Pool(4) 
    
        result1 = pool.map(f1, [ [1,2,3] ])
        print(result1)
    

提交回复
热议问题