multiprocessing.pool.map and function with two arguments

后端 未结 5 1792
臣服心动
臣服心动 2020-12-15 10:54

I am using multiprocessing.Pool()

here is what i want to Pool:

def insert_and_process(file_to_process,db):
    db = DAL(\"path_to_mysql\         


        
5条回答
  •  再見小時候
    2020-12-15 11:12

    No need to use zip. If for example you have 2 parameters, x and y, and each of them can get several values, like:

    X=range(1,6)
    Y=range(10)
    

    The function should get only one parameter, and unpack it inside:

    def func(params):
        (x,y)=params
        ...
    

    And you call it like that:

    params = [(x,y) for x in X for y in Y]
    pool.map(func, params)
    

提交回复
热议问题